gridview设置背景字体颜色

 protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            string stat_name = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "状态")).Trim();
            if (stat_name == "待审核")
            {
                e.Row.Cells[5].ForeColor = Color.Red;
            }
            else if (stat_name.Substring(0, 4) == "审核通过")
            {
                e.Row.Cells[5].ForeColor = Color.Green;
            }
           
        }

    }

你可能感兴趣的:(gridview设置背景字体颜色)