mrcoulson
asked on
How can I change the color of gridview row based on value of cell?
I am trying to turn a row in a gridview red if a column has a value of 0. My code is attached. I'm told "Non-invocable member 'System.Web.UI.WebControls .GridViewR ow.DataIte m' cannot be used like a method". How should I handle this?
Jeremy
Jeremy
protected void gvBeneficiary_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.DataItem("units_built") == 0)
{
e.Row.BackColor = Color.Red;
}
}
Protected Sub GridView1_RowDataBound(ByV al sender As Object, ByVal e As System.Web.UI.WebControls. GridViewRo wEventArgs )
Sub GridView1_RowDataBound(ByV al sender As Object, ByVal e As System.Web.UI.WebControls. GridViewRo wEventArgs )
If e.Row.RowType = DataControlRowType.DataRow Then
If (e.Row.DataItem("UnitsInSt ock") < 20) Then
e.Row.BackColor = Drawing.Color.Red
End If
End If
End Sub
Sub GridView1_RowDataBound(ByV
If e.Row.RowType = DataControlRowType.DataRow
If (e.Row.DataItem("UnitsInSt
e.Row.BackColor = Drawing.Color.Red
End If
End If
End Sub
ASKER
rkworlds: That's where I got the code that didn't work.
Jeremy
Jeremy
ASKER
roshmon: Why does that create a label?
Jeremy
Jeremy
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
the VB.net code shows here
Open in new window