Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# RowDataBound上Gridview行的背景色在IE11中不起作用_C#_Asp.net_Rowdatabound - Fatal编程技术网

C# RowDataBound上Gridview行的背景色在IE11中不起作用

C# RowDataBound上Gridview行的背景色在IE11中不起作用,c#,asp.net,rowdatabound,C#,Asp.net,Rowdatabound,我有Grd_RowDataBound,我正在对我的GridView行应用背景色。我使用了下面的代码,它在Crome和Mozilla中运行良好,但在IE11中运行不正常 protected void Grd_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { string Sta

我有
Grd_RowDataBound
,我正在对我的GridView行应用背景色。我使用了下面的代码,它在Crome和Mozilla中运行良好,但在IE11中运行不正常

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

请帮助。

尝试以下方法:

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";
            }
        }        
    }
希望这对你有帮助