Monday, August 23, 2010

Change GridView RowColor

How to change gridview row color and use css class.
Below code describe how to call css class at runtime for change the gridview row color.
protected void gv_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
string checkstatus= Convert.ToString(DataBinder.Eval(e.Row.DataItem,"checkstatus"));
if (checkstatus == "Pending")
{
e.Row.Cells[0].BackColor="css class";
}
else
{
e.Row.Cells[0].BackColor="css class";
}
}
}

Thanks & Regards
Santosh

2 comments: