设置GridView指定行的特殊颜色

        添加GridView的RowDataBound事件:
        protected void GridViewChuXing_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            try
            {
                if (e.Row.RowType == DataControlRowType.DataRow)
                {
                    int flag = Convert.ToInt32(DataBinder.Eval(e.Row.DataItem, "flag"));
                    if (flag ==0)
                    {
                        e.Row.BackColor = System.Drawing.Color.Red;
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }

你可能感兴趣的:(设置GridView指定行的特殊颜色)