Skip to main content
A newer version of this page is available. .
Tab

ASPxGridView.HtmlDataCellPrepared Event

Enables you to change individual cell settings.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v19.2.dll

Declaration

public event ASPxGridViewTableDataCellEventHandler HtmlDataCellPrepared

Event Data

The HtmlDataCellPrepared event's data class is ASPxGridViewTableDataCellEventArgs. The following properties provide information specific to this event:

Property Description
Cell Gets the processed data cell.
CellValue Gets the processed cell’s value.
DataColumn Gets the data column that owns the cell currently being processed.
KeyValue Gets an object that uniquely identifies the data row. Inherited from ASPxGridViewItemEventArgs.
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 grid raises the HtmlDataCellPrepared event for each data cell in the ASPxGridView when the corresponding table cell has been created. You can handle this event to change the style settings of individual cells.

The processed cell is identified by the event parameter’s ASPxGridViewTableDataCellEventArgs.Cell property. Its value is returned by the ASPxGridViewTableDataCellEventArgs.CellValue property. The column and row where the processed cell resides can be obtained via the ASPxGridViewTableDataCellEventArgs.DataColumn and ASPxGridViewItemEventArgs.KeyValue properties.

Note

The grid raises this event for visible rows only. For example, the event is raised for rows displayed in a currently selected page when you page data.

Example

In this example, the ASPxGridView.HtmlDataCellPrepared event is handled to highlight the Budget column’s cells whose values are less than 100,000.

The image below shows the result:

HtmlDataCellPrepared

protected void ASPxGridView1_HtmlDataCellPrepared(object sender,
    DevExpress.Web.ASPxGridViewTableDataCellEventArgs e) {
    if (e.DataColumn.FieldName != "Budget") return;
    if (Convert.ToInt32(e.CellValue) < 100000)
        e.Cell.BackColor = System.Drawing.Color.LightCyan;
}
See Also