G
Guest
I'm trying to use a datagrid to display data and that has been easy - what
i'm trying to do is have a rows background color change to red if the first
databound column is 0 for the item. I have entered an onitemcreated sub
routine to handle the data item when its added to the grid but it hasn't
worked. This is my sub below:
Sub OnCreatedItem(ByVal sender As Object, ByVal e As
DataGridItemEventArgs)
If e.Item.Cells(0).Text = "0" Then
UnitLists.Items(e.Item.ID).BackColor =
System.Drawing.Color.ForestGreen
'e.Item.BackColor = System.Drawing.Color.ForestGreen
End If
End Sub
I was told by another user to use the ItemDataBinding event and to use the
following code:
Dim rw as DataRowView = e.item.DataItem
if rw!=null
rw(0).Equals("0")
or something similar this
But the e variable that has to be passed is for type EventArgs and does not
contain data for the table rows that are created. Any more ideas?
How do i code this so I can vary the background colors for the cells
depending on the data that it contains?
Thank you for your help,
Ryan
i'm trying to do is have a rows background color change to red if the first
databound column is 0 for the item. I have entered an onitemcreated sub
routine to handle the data item when its added to the grid but it hasn't
worked. This is my sub below:
Sub OnCreatedItem(ByVal sender As Object, ByVal e As
DataGridItemEventArgs)
If e.Item.Cells(0).Text = "0" Then
UnitLists.Items(e.Item.ID).BackColor =
System.Drawing.Color.ForestGreen
'e.Item.BackColor = System.Drawing.Color.ForestGreen
End If
End Sub
I was told by another user to use the ItemDataBinding event and to use the
following code:
Dim rw as DataRowView = e.item.DataItem
if rw!=null
rw(0).Equals("0")
or something similar this
But the e variable that has to be passed is for type EventArgs and does not
contain data for the table rows that are created. Any more ideas?
How do i code this so I can vary the background colors for the cells
depending on the data that it contains?
Thank you for your help,
Ryan