ASPxGridView.HtmlRowPrepared Event
Enables the settings of individual rows to be changed.
Namespace: DevExpress.Web
Assembly: DevExpress.Web.v24.1.dll
NuGet Package: DevExpress.Web
Declaration
Event Data
The HtmlRowPrepared event's data class is ASPxGridViewTableRowEventArgs. The following properties provide information specific to this event:
Property | Description |
---|---|
KeyValue | Gets an object that uniquely identifies the row. |
Row | Gets the processed row. |
RowType | Gets the processed row’s type. |
VisibleIndex | Gets the visible index of the data row. Inherited from ASPxGridViewItemEventArgs. |
The event data class exposes the following methods:
Method | Description |
---|---|
GetValue(String) | Returns the value of the specified cell within the processed row. |
Remarks
The HtmlRowPrepared event is raised for each grid row (data row, group row, etc.) within the ASPxGridView. You can handle this event to change the style settings of individual rows.
Note
During export operations, the Grid View control ignores appearance settings specified in the HtmlRowPrepared event handler. Refer to the following topic for more information on how to customize exported elements in different export modes: Export Modes.
The HtmlRowPrepared and ASPxGridView.HtmlRowCreated events are not fired for the grid’s column header row and title row. So, the ASPxGridViewTableRowEventArgs.RowType property is never set to GridViewRowType.Title or GridViewRowType.Header within these event arguments.
GitHub Examples
Example
In this example, the HtmlRowPrepared event is handled to highlight the products whose price is less than $20 or more than $50.
protected void ASPxGridView1_HtmlRowPrepared(object sender, DevExpress.Web.ASPxGridViewTableRowEventArgs e) {
if (e.RowType != GridViewRowType.Data) return;
int price = Convert.ToInt32(e.GetValue("UnitPrice"));
if (price < 20)
e.Row.BackColor = System.Drawing.Color.LightCyan;
if (price > 50)
e.Row.ForeColor = System.Drawing.Color.DarkRed;
}