Wednesday, 4 April 2012

To change the particular row color of the grid in ASP.Net

 protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {

            if (DataBinder.Eval(e.Row.DataItem, "StaffName").ToString() == "Ram")
            {
                // color the background of the row yellow
                e.Row.BackColor = Color.Yellow;
                e.Row.ForeColor = Color.Green;
            }
 
        }
    }

No comments:

Post a Comment