gpt4 book ai didi

c# - 根据条件更改行的颜色

转载 作者:行者123 更新时间:2023-12-02 21:39:33 24 4
gpt4 key购买 nike

我想根据某些条件更改 gridview 的特定行颜色,我正在使用 ASP.NET 和 c#。

我知道我可以使用 HTMLCellPrepared 方法,但在我的方法中我也想查看其他网格的值?这可能吗?

    protected void GVResults_HtmlDataCellPrepared(object sender, ASPxGridViewTableDataCellEventArgs e)
{
if (e.DataColumn.FieldName == "CarrierId")
if ( Convert.ToInt32(e.CellValue) > 0)
e.Cell.ForeColor = System.Drawing.Color.Red;
}

这是该方法的第一部分,但我想查看其他网格中的值,以便对此网格进行视觉更改。问题是我不知道如何从其他网格访问值......

最佳答案

我建议您使用 htmlrowprepared 事件来对行进行条件着色。

根据您编写的代码,下面的示例可以帮助您:

protected void GVResults_HtmlRowPrepared(object sender, ASPxGridViewTableRowEventArgs e)
{
if (e.RowType != GridViewRowType.Data) return;
int value = (int)e.GetValue("CarrierId");
if (value > 0)
e.Row.ForeColor = System.Drawing.Color.Red;
}

引用:
Changing ASPxGridView Cell and Row Color on Condition

关于c# - 根据条件更改行的颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20678244/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com