Gridview中修改某列的背景色

时间:2021-07-27 14:48:16

Gridview中状态列的值是1,某列的背景是是绿色
状态字段是:archivesStatus
 protected void gvInfo_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {            
            for (int i = 0; i <= gvInfo.Rows.Count ; i++)
            {                
                string bqred = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "archivesStatus"));
                if (bqred == "1")
                {
                    e.Row.Cells[14].BackColor = System.Drawing.Color.Green;
                }                
            }
        }
    }