David Wier wrote:
Check out this code sample at ASPNet101.com:
http://aspnet101.com/aspnet101/aspne...de=gvcellcolor
David Wier
MVP/ASPInsider
http://aspnet101.com
http://aspexpress.com
The example you pointed me to worked like a charm. Thanks for your help!
Here's my code in case anyone is curious.
In the aspx file:
<asp:GridView ID="gvData" runat="server" OnRowDataBound= "doColor">
In the aspx.vb file (the btnSubmit sub is cut down for space):
Sub doColor(ByVal sender As Object, ByVal e As GridViewRowEven tArgs)
If e.Row.RowType = DataControlRowT ype.DataRow Then
If e.Row.Cells(10) .Text "44" Then
e.Row.BackColor = Drawing.Color.L ightYellow
e.Row.Cells(10) .ForeColor = Drawing.Color.R ed
e.Row.Cells(10) .Font.Bold = True
End If
If e.Row.Cells(11) .Text "59" Then
e.Row.BackColor = Drawing.Color.L ightYellow
e.Row.Cells(11) .ForeColor = Drawing.Color.R ed
e.Row.Cells(11) .Font.Bold = True
End If
End If
End Sub
Protected Sub btnSubmit_Click (ByVal sender As Object, ByVal e As
System.EventArg s) Handles btnSubmit.Click
objConnection.O pen()
gvData.DataSour ce =
objCommand.Exec uteReader(Comma ndBehavior.Clos eConnection)
gvData.DataBind ()
If objConnection.S tate = ConnectionState .Open Then
objConnection.C lose()
End If
End Sub