2014-09-03 60 views
4

我有Grd_RowDataBound,我正在将颜色应用到GridView行。我用下面的代码在Crome和Mozilla中工作正常,但不工作在IE11。在IE11中,我的Gridview行背景颜色不起作用。RowDataBound上的Gridview行的背景颜色在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 
      } 
     }   
    } 

请帮忙。

回答

2

尝试这样:

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

希望这可以帮助你!