ASP.NET/C# - ASPxGridView 条件格式
本文关键字:ASPxGridView 条件 格式 NET ASP | 更新日期: 2023-09-27 18:35:53
但是
,当我使用此代码时,我试图只突出显示一个单元格而不是整行:
public bool ProcessSelectionChangedOnServer { get; set; }
protected void ASPxGridView1_HtmlDataCellPrepared(object sender,
DevExpress.Web.ASPxGridViewTableDataCellEventArgs e)
{
if (e.GetValue("BusType").ToString() == "CUS")
{
e.Cell.BackColor = System.Drawing.Color.LightCyan;
}
}
它似乎突出显示了BusType
等于"CUS"的整行。谁能指出我正确的方向?提前谢谢。
编辑:我试图添加
e.DataColumn.CellStyle.BackColor = System.Drawing.Color.LightCyan;
并删除e.Cell.BackColor
行,但这并没有突出显示任何内容
我遇到了一些评论,实际上解决了我的答案。修复很容易,我必须确保正在检查的列是正确的。
参考:
ASPxGridView - 单元格条件格式
法典:
if (e.DataColumn.FieldName == "BusType")
{
if (e.GetValue("BusType").ToString() == "CUS")
{
e.Cell.BackColor = System.Drawing.Color.LightCyan;
e.Cell.ForeColor = System.Drawing.Color.DarkRed;
// and so on...
}
}