David said:
I have a need to make a GridView row a different color (red) if a date
exists on the row. I assume I would do this in the OnDataBound event. I
know how to make a Cell(x) a different color but not a row. Thanks.
David
Here's some code I put together a while back as an additional example to
John's reply. Watch for wrap!
Sub doColor(ByVal sender As Object, ByVal e As GridViewRowEventArgs)
Dim test As New BoundColumn()
If e.Row.RowType = DataControlRowType.DataRow Then
Dim i9, i10 As Integer
If Int32.TryParse(e.Row.Cells(9).Text, i9) AndAlso i9 >= 45
Then
e.Row.BackColor = Drawing.Color.LightYellow
e.Row.Cells(9).ForeColor = Drawing.Color.Red
e.Row.Cells(9).Font.Bold = True
End If
If Int32.TryParse(e.Row.Cells(9).Text, i9) AndAlso i9 < 0 Then
e.Row.BackColor = Drawing.Color.Yellow
e.Row.Cells(9).ForeColor = Drawing.Color.Red
e.Row.Cells(9).Font.Bold = True
End If
If Int32.TryParse(e.Row.Cells(10).Text, i10) AndAlso i10 >=
60 Then
e.Row.BackColor = Drawing.Color.LightYellow
e.Row.Cells(10).ForeColor = Drawing.Color.Red
e.Row.Cells(10).Font.Bold = True
End If
End If
End Sub