Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Updating the Cell Color in a datagrid on a webform
Message
General information
Forum:
ASP.NET
Category:
WebForms
Miscellaneous
Thread ID:
00672063
Message ID:
00672130
Views:
8
Cathi

Thanks for your help (again). I was able to accomplish what I needed and I have pasted my version (part of it) below. Since there doesn't seem to be a way to loop though each column, I have to repeat the code over and over. In my project, I have 48 column cells I have to check and color. Anyway, thanks again, hopefully others can use this as well.
   Dim tempString as String
   Dim iValue as Integer

   If e.Item.ItemType = ListItemType.Item OrElse e.Item.ItemType = ListItemType.AlternatingItem Then
      tempString = DataBinder.Eval(e.Item.DataItem, "T0600").ToString()
      iValue = Integer.Parse(tempString)
      If iValue > 0 Then
         e.Item.Cells(1).BackColor = Color.Red
      Else
         e.Item.Cells(1).BackColor = Color.LightGreen
      End If

      tempString = DataBinder.Eval(e.Item.DataItem, "T0615").ToString()
      iValue = Integer.Parse(tempString)
      If iValue > 0 Then
         e.Item.Cells(2).BackColor = Color.Red
      Else
         e.Item.Cells(2).BackColor = Color.LightGreen
      End If

      tempString = DataBinder.Eval(e.Item.DataItem, "T0630").ToString()
      iValue = Integer.Parse(tempString)
      If iValue > 0 Then
         e.Item.Cells(3).BackColor = Color.Red
      Else
         e.Item.Cells(3).BackColor = Color.LightGreen
      End If

      tempString = DataBinder.Eval(e.Item.DataItem, "T0645").ToString()
      iValue = Integer.Parse(tempString)
      If iValue > 0 Then
         e.Item.Cells(4).BackColor = Color.Red
      Else
         e.Item.Cells(4).BackColor = Color.LightGreen
     End If
end if
Previous
Reply
Map
View

Click here to load this message in the networking platform