In addition to above solution.
the row color can also be changed using
Style
attributes
either after the calling the
databind()
method or inside the
RowDatabound
event
gv.DataSource = data;
gv.DataBind();
gv.Rows[4].BackColor = System.Drawing.Color.Red;
protected void gv_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (e.Row.RowIndex == 3)
{
e.Row.Style.Add("background-color", "green");
e.Row.BackColor = System.Drawing.Color.Green;
}
}
}