根据绑定的值的不同改变gridview里某一单元格的字体或背景颜色
第一种
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (Convert.ToInt32(e.Row.Cells[3].Text.Trim()) >5)
{
e.Row.BackColor = Color.Red;
}
}
}
第二种
<ItemTemplate>
<span style=' <%# "color:" + (Eval("yourField").ToString() == "1" ? "black" : (Eval ("yourField").ToString() == "2") ? "green" : "red" ) %> '> <%# Eval("xxx") %> </span>
</ItemTemplate>