您的位置:首页 > 编程语言 > ASP

[ASP.NET] GridView 依條件更改某列背景顏色

2014-04-01 20:21 405 查看
protected void gvList_RowDataBound(object sender, GridViewRowEventArgs e)
{
DataRowView drv = (DataRowView)e.Row.DataItem;

if ((e.Row.RowType == DataControlRowType.DataRow) || (e.Row.RowType == DataControlRowType.Footer))
{
if (drv != null)
{
if (drv["arttype"].ToString().Trim() == "A")  //條件式
{
e.Row.Attributes.Add("style", "background-color:#f0d5b3"); //新增背景色屬性
}
}
}
}

12        }

13     }

14    }
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: