Change font color in gridview loop
Posted on 2007-04-10
I have a gridview in asp.net that has a column displaying "Amount Due" values. I want to loop through the grid and display the values greater than zero in red font. This is what I have attempted, and it doesn't work. I get an 'object not referenced' error. Does anyone have a way to do this?
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim amtDue As Label = DirectCast(gvMyGroups.FindControl("lblAmountDue"), Label)
For Each amtDue In gvMyGroups.Rows
If amtDue.Text > 0 Then
amtDue.ForeColor = Drawing.Color.DarkRed