ASPxGridView.InitNewRow Event
Enables you to initialize added rows.
Namespace: DevExpress.Web
Assembly: DevExpress.Web.v20.2.dll
NuGet Package: DevExpress.Web
Declaration
Event Data
The InitNewRow event's data class is ASPxDataInitNewRowEventArgs. The following properties provide information specific to this event:
Property | Description |
---|---|
NewValues | Gets a dictionary that contains the new field name/value pairs for the new row. |
Remarks
The InitNewRow event is raised when a new row is added to the ASPxGridView. This occurs when:
- the ASPxClientGridView.AddNewRow or ASPxGridView.AddNewRow method is called;
- an end-user has clicked on the New command button.
Use the event parameter’s NewValues property to specify the values in the new row. 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, handle the ASPxGridView.RowInserting event.
Example
In this example the ASPxGridView.InitNewRow
event is handled to initialize the new record’s field values with default values.
The image below shows the result:
protected void grid_InitNewRow(object sender, DevExpress.Web.Data.ASPxDataInitNewRowEventArgs e) {
e.NewValues["BirthDate"] = new DateTime(1970, 1, 10);
e.NewValues["Title"] = "Sales Representative";
}