5

我有Grd_RowDataBound并且我正在将颜色应用到我的 GridView 行。我使用了下面的代码,它在 Crome 和 Mozilla 中运行良好,但在 IE11 中不起作用。在 IE11 中,我的 Gridview 行背景颜色不起作用。

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
            }
        }        
    }

请帮忙。

4

1 回答 1

3

尝试这样的事情:

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";
            }
        }        
    }

希望这可以帮助你!

于 2014-09-03T09:59:47.817 回答