Skip to main content

GridViewSettings.HtmlRowPrepared Property

Enables the settings of individual rows to be changed.

Namespace: DevExpress.Web.Mvc

Assembly: DevExpress.Web.Mvc5.v24.1.dll

NuGet Package: DevExpress.Web.Mvc5

Declaration

public ASPxGridViewTableRowEventHandler HtmlRowPrepared { get; set; }

Property Value

Type Description
ASPxGridViewTableRowEventHandler

A ASPxGridViewTableRowEventHandler delegate method allowing you to implement custom processing.

Remarks

The HtmlRowPrepared event is raised for each row, displayed within the current page, when the corresponding HTML table row has been prepared, but has not yet been rendered. You can handle this event to change the style settings of individual rows.

Example

The code sample below demonstrates how to change the style of a row based on one of its values.

View code:

@Html.DevExpress().GridView(settings => {
    settings.Name = "GridView";
    settings.CallbackRouteValues = new { Controller = "Home", Action = "GridViewPartial" };
    settings.KeyFieldName = "ProductID";
    settings.Columns.Add("ProductName");
    // ...

    // Discontinued items are displayed in gray font.
    settings.HtmlRowPrepared = (s, e) => {
        if (Convert.ToBoolean(e.GetValue("Discontinued")) == true) {
            e.Row.ForeColor = System.Drawing.Color.DarkGray;
        }
    };
}).Bind(Model).GetHtml()

The image below illustrates the result.

MVC_Grid_Rows_HtmlRowPrepared

See Also