aspnetmvc-devexpress-dot-web-dot-mvc-dot-gridviewsettings-c0d4e145.md
Enables you to initialize added rows.
Namespace : DevExpress.Web.Mvc
Assembly : DevExpress.Web.Mvc5.v25.2.dll
NuGet Package : DevExpress.Web.Mvc5
public ASPxDataInitNewRowEventHandler InitNewRow { get; set; }
Public Property InitNewRow As ASPxDataInitNewRowEventHandler
| Type | Description |
|---|---|
| ASPxDataInitNewRowEventHandler |
A delegate method that allows you to specify initial values.
|
The initialization of a new row added to the GridView occurs when:
Use the argument’s NewValues property to specify the values in the new row.
@Html.DevExpress().GridView(settings => {
settings.Name = "GridView";
// ...
settings.KeyFieldName = "CustomerID";
settings.Columns.Add("CompanyName");
settings.Columns.Add("ContactName");
settings.Columns.Add("ContactTitle");
settings.Columns.Add("Phone");
// Process the initialization of new rows.
settings.InitNewRow = (s, e) => {
e.NewValues["Phone"] = "(5) 555-12-34";
e.NewValues["ContactTitle"] = "Owner";
};
}).Bind(Model).GetHtml()
The image below illustrates the edit form that appears after a user clicks the New button.
Note that you can initialize values only for those columns that are visible within the Edit Form or In-Line Edit Row. To specify values of hidden columns, modify the properties of a model object passed to an action method specified via the MVCxGridViewEditingSettings.AddNewRowRouteValues property.
View Example: How to implement row clone functionality
See Also