Change a Datagrid cell background
Hello all
I'm trying to change a cell of a datagrid background when a condition becomes true.let me explain more:
I have a datagrid with different columns.one of these columns is a string that contains "0"s and "1"s.i want to check this cell.for example if the first character was "1" then the first cell should have a different background column and so on.
I wrote my codes like this:
1-a datagrid that has OnDataBinding(it calls a sub)
2-my sub is like this:
sub Changebg(s As Object,e As System.EventArgs)
for each myItem As DataGridItem in DataGrid1.Items
if first char="1" then
change the first cell background
if second char="1" then
change the second cell background
and so on ......
but it doesn't change any cell background
and this is the code for accessing the string field:
c=myItems.cells(12).text
and for changin the background i used:
myItem.cells(1).BackColor=skyblue
would you please help me.I'm not familiar with .net and i think i didn't use these codes correctly
i would be very happ if some one help me
thank you
|