Back to Devexpress

GridViewSettings.HtmlRowPrepared Property

aspnetmvc-devexpress-dot-web-dot-mvc-dot-gridviewsettings-d410a0c6.md

latest2.5 KB
Original Source

GridViewSettings.HtmlRowPrepared Property

Enables the settings of individual rows to be changed.

Namespace : DevExpress.Web.Mvc

Assembly : DevExpress.Web.Mvc5.v25.2.dll

NuGet Package : DevExpress.Web.Mvc5

Declaration

csharp
public ASPxGridViewTableRowEventHandler HtmlRowPrepared { get; set; }
vb
Public Property HtmlRowPrepared As ASPxGridViewTableRowEventHandler

Property Value

TypeDescription
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:

csharp
@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.

See Also

Declaring Server-Side Event Handlers

Grid View

Traversing Rows

GridViewSettings Class

GridViewSettings Members

DevExpress.Web.Mvc Namespace