Background color of Gridview row on RowDataBound is not working in IE11

Genish Parvadia picture Genish Parvadia · Sep 3, 2014 · Viewed 9.9k times · Source

I have Grd_RowDataBound and I am applying back color to my GridView Rows. I have used below code which is working fine in Crome and Mozilla ,but not working in IE11.In IE11 my Gridview row back color is not working.

protected void Grd_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            string Status = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "Visit_Status"));

            if (Status == "1")
            {
                e.Row.BackColor = ColorTranslator.FromHtml("#28b779");//81F79F
            }
            else
            {
                e.Row.BackColor = ColorTranslator.FromHtml("#da5554");//F78181
            }
        }        
    }

Please help.

Answer

Krupa Patel picture Krupa Patel · Sep 3, 2014

Try something like this:

protected void Grd_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            string Status = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "Visit_Status"));

            if (Status == "1")
            {
                e.Row.Attributes["style"] = "background-color: #28b779";
            }
            else
            {
                e.Row.Attributes["style"] = "background-color: #da5554";
            }
        }        
    }

Hope this may help you!