作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想根据某些条件更改 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;
}
关于c# - 根据条件更改行的颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20678244/
我是一名优秀的程序员,十分优秀!