aspnetmvc-devexpress-dot-web-dot-mvc-dot-gridviewsettings-d410a0c6.md
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
public ASPxGridViewTableRowEventHandler HtmlRowPrepared { get; set; }
Public Property HtmlRowPrepared As ASPxGridViewTableRowEventHandler
| Type | Description |
|---|---|
| ASPxGridViewTableRowEventHandler |
A ASPxGridViewTableRowEventHandler delegate method allowing you to implement custom processing.
|
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.
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.
See Also