Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I originally had a datagrid bound to a dataset. After loading the dataset, I would loop through it and make changes to the datagrid background colors based on values in the dataset. The code was something like:

 

if myDataset.myDataTable(i).STATUS = "C" then

myDatagrid.items(i).cells(1).BackColor = Color.Red

end if

 

That worked fine. I now have to added sorting capability. I've bound the datagrid to a dataview so that I can set the dataview.sort property. The problem now is that when I do a datagrid.databind, I loose the formatting of the datagrid. It does do the sorting though.

 

Any ideas on how I can do both the sorting and make changes to individual cell appearances?

Posted

Checking Value of Datagrid Cells

 

I originally had a datagrid bound to a dataset. After loading the dataset, I would loop through it and make changes to the datagrid background colors based on values in the dataset. The code was something like:

 

if myDataset.myDataTable(i).STATUS = "C" then

myDatagrid.items(i).cells(1).BackColor = Color.Red

end if

 

That worked fine. I now have to added sorting capability. I've bound the datagrid to a dataview so that I can set the dataview.sort property. The problem now is that when I do a datagrid.databind, I loose the formatting of the datagrid. It does do the sorting though.

 

Any ideas on how I can do both the sorting and make changes to individual cell appearances?

 

 

OK, it appears that the datagrid.databind resets the format on the datagrid. I can actually live with that if I databind (sort) first and then make changes to cell appearances in the datagrid.

 

My new problem is that I can't set a cell's color based on the datatable's value any more because the sort changes the relationship between the grid and the dataset. After the sort, the second "row" of the dataset isn't necessarily displayed in the second row of the datagrid.

 

Instead of checking the value of myDataset.myDataTable(i).STATUS , I thought I could check the value of myDatagrid.items(i).cells(1).text (The STATUS value is stored in the 1st column.) However, myDatagrid.items(i).cells(1).text always seems to be Nothing, even after I do DataBind. I can do myDatagrid.items(i).cells(1).text = "Something", and it will display "Something". However, I can't seem to check the value.

 

Thanks for any help.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...