GridViewSettings.InitNewRow Property
Enables you to initialize added rows.
Namespace: DevExpress.Web.Mvc
Assembly: DevExpress.Web.Mvc5.v24.2.dll
Declaration
Property Value
Type | Description |
---|---|
ASPxDataInitNewRowEventHandler | A delegate method that allows you to specify initial values. |
Remarks
The initialization of a new row added to the GridView occurs when:
- the client ASPxClientGridView.AddNewRow method is called;
- an end-user clicks on the New command button.
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.
Online Example
See Also