Highlight GridView row when a condition is met
Yes, add OnRowDataBound="yourGridview_RowDataBound"
to your gridview. This event gets triggered for every gridview row.
In the code behind, have this:
public void yourGridview_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
// do your stuffs here, for example if column risk is your third column:
if (e.Row.Cells[2].Text == "high")
{
e.Row.BackColor = Color.Red;
}
}
}
Use RowDataBound Event. In this event you would get to add the css based upon your condition
void GridView_RowDataBound(Object sender, GridViewRowEventArgs e)
{
if(e.Row.RowType == DataControlRowType.DataRow)
{
// Logic for High
if(e.Row.Cells[1].Text > 100)
//set color
e.Row.Attributes.Add("style", "this.style.backgroundColor = '#FFFFFF';");
}
}