添加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);
}
}
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);
}
}