Initializing New Rows
The GridView extension allows you to define the default field values displayed within the built-in edit form for the newly added records.
To initialize row values in code, define the initial values in the ASPxDataInitNewRowEventArgs.NewValues dictionary within a delegate method, and assign this delegate method to the GridViewSettings.InitNewRow property.
@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.