Saturday, May 15, 2010

Gridview Background color setting based on Data

Protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if(e.Row.RowType==DataControlRowType.DataRow)
{
//Retives the DataItem value from row into Marks variable
//Total_Marks is Grdview database coloumn name
int Marks=(int)DataBinder.Eval(e.Row.DataItem, "Total_Marks");
if(Marks>500)
e.Row.BackColor=System.Drawing.Color.Red;
else
e.Row.BackColor=System.Drawing.Color.Blue;
}
}

No comments:

Post a Comment