How to change the gridview row color in asp.net [Resolved]

Posted by Allemahesh under ASP.NET on 7/1/2013 | Points: 10 | Views : 13003 | Status : [Member] [MVP] | Replies : 1
I have a grid-view. I want to change the grid-view row colors from code behind file.




Responses

Posted by: Jaskumar on: 7/2/2013 [Member] Starter | Points: 25

Up
0
Down
Use This code of Gridview Row bound event

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{

if (e.Row.RowType == DataControlRowType.DataRow)
{
string quantity = e.Row.Cells[5].Text;

foreach (TableCell cell in e.Row.Cells)
{
if (quantity == "Mumbai")
{
e.Row.Cells[5].BackColor = Color.Red;
}

}
}
}

Jas

Allemahesh, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response