【发布时间】:2014-09-16 19:52:38
【问题描述】:
我正在使用 RadGrid 来显示数据库中的数据。如果在状态列中该行显示为“REJECTED”,我想将 RadGrid 中的行颜色更改为红色。如果状态为 NULL,则该行将保持显示为白色。我已经尝试过这段代码,但该行仍然没有将颜色变为红色。
try
{
if (dataBoundItem["status"].Text == "REJECTED")
{
TableCell cell = (TableCell)dataBoundItem["status"];
cell.BackColor = System.Drawing.Color.Red;
dataBoundItem.BackColor = System.Drawing.Color.Red;
if (e.Item is GridDataItem)
{
GridDataItem dataBoundItem1 = e.Item as GridDataItem;
if (dataBoundItem1["Status"].Text != null)
{
cell.BackColor = System.Drawing.Color.Red;
dataBoundItem1.BackColor = Color.Red;
dataBoundItem1["status"].ForeColor = Color.Red;
dataBoundItem1["status"].Font.Bold = true;
}
}
}
}
catch
{ }
【问题讨论】:
-
能否提供 radgrid 标记代码?