怎样动态改变GridView特定行的背景色
GridView数据有 会员代码 会员名称 会员类别 三列 怎样将会员类别这一列数据中 为"预警"的行的背景色变成红色
{
e.Row.Attributes.Add("class", "yellow");
System.Web.UI.WebControls.Button btn = e.Row.FindControl("Button1") as System.Web.UI.WebControls.Button;
btn.Text = "确认订单";
btn.CommandName = "Confirm";
btn.CommandArgument = orderid;
}
[解决办法]
protected void gv_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (DataBinder.Eval(e.Row.DataItem, "前台类别名称字段") == "预警")
{
e.Row.Style.Add("background-color", "#b3d3ec");
}
}
}