I want to switch font colours depending on a value - this code works great when the form loads but errors on the lbl.ForeColor = Drawing.Color.Red
when I try to update - it doesn't seem to find the label
Protected Sub GridView3_RowCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView3.RowCreated
If e.Row.RowType = DataControlRowType.DataRow Then
Dim lbl As Label = CType(e.Row.FindControl("Label1"), Label)
If DataBinder.Eval(e.Row.DataItem, "Over_Under") < 0D Then
lbl.ForeColor = Drawing.Color.Red
Else
lbl.ForeColor = Drawing.Color.Blue
End If
End If
End Sub
when I try to update - it doesn't seem to find the label
Protected Sub GridView3_RowCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView3.RowCreated
If e.Row.RowType = DataControlRowType.DataRow Then
Dim lbl As Label = CType(e.Row.FindControl("Label1"), Label)
If DataBinder.Eval(e.Row.DataItem, "Over_Under") < 0D Then
lbl.ForeColor = Drawing.Color.Red
Else
lbl.ForeColor = Drawing.Color.Blue
End If
End If
End Sub