Reputation: 327
I want to change a particular row color of gridview based on some condition, i am using ASP.NET with c#.
I know i can use the HTMLCellPrepared method, but in my method i want to look at the values of other grids as well? Is this possible?
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;
}
This is the first part of the method, but i want to look at values from other grids in order to make visual changes to this grid. Problem is I dont know how to access values from other grids....
Upvotes: 2
Views: 7457
Reputation: 1236
I would recommend you to use the htmlrowprepared event for the conditional coloring of row.
According to the code you have written, below example can help you :
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;
}
Reference:
Changing ASPxGridView Cell and Row Color on Condition
Upvotes: 4
Reputation: 4101
You can use RowDataBound
event of GridView to check a condition if your styling depends on data and set a style for that condition.
Here is an example of this.
Upvotes: 1