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

ASPxGridView.HtmlRowCreated Event

Occurs when a table row has been created.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v18.2.dll

Declaration

public event ASPxGridViewTableRowEventHandler HtmlRowCreated

Event Data

The HtmlRowCreated 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 HtmlRowCreated event is raised for each grid row (data row, group row, etc.) within the ASPxGridView when the corresponding table row has been created. You can handle this event to initialize web controls contained within the grid templates.

The HtmlRowCreated and ASPxGridView.HtmlRowPrepared 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.

Example

In this example, the ASPxGridView.HtmlRowCreated event is handled to dynamically change the images displayed within the Change column’s cells. These images are contained within the Change column’s GridViewDataColumn.DataItemTemplate and indicate how symbol values are changed on a market.

The image below shows the result:

exHtmlRowCreated


using System.Web.UI.WebControls;
...
protected void grid_HtmlRowCreated(object sender, 
DevExpress.Web.ASPxGridViewTableRowEventArgs e) {
    if(e.RowType != DevExpress.Web.GridViewRowType.Data) return;
    Label label = grid.FindRowCellTemplateControl(e.VisibleIndex, null, "changePercent") as Label;
    decimal change = (decimal)e.GetValue("Change");
    label.Text = string.Format("{0:p}", change);
    Image img = grid.FindRowCellTemplateControl(e.VisibleIndex, null, "changeImage") as Image;
    img.Visible = false;
    if(change != 0) {
        img.Visible = true;
        img.ImageUrl = change < 0 ? "~/Images/arRed.gif" : "~/Images/arGreen.gif";
    }
}
See Also