Back to Devexpress

How to: Add and Initialize a New Row

aspnet-3749-components-grid-view-examples-how-to-add-and-initialize-a-new-row.md

latest913 B
Original Source

How to: Add and Initialize a New Row

  • Sep 30, 2021

This example handles the ASPxGridView.InitNewRow event to initialize the new record’s field values with default values.

The image below shows the result:

csharp
protected void grid_InitNewRow(object sender, DevExpress.Web.Data.ASPxDataInitNewRowEventArgs e) {
    e.NewValues["BirthDate"] = new DateTime(1970, 1, 10);
    e.NewValues["Title"] = "Sales Representative";
}
vb
Protected Sub ASPxGridView1_InitNewRow(ByVal sender As Object,_
    ByVal e As DevExpress.Web.Data.ASPxDataInitNewRowEventArgs) Handles ASPxGridView1.InitNewRow
    e.NewValues("BirthDate") = New DateTime(1970, 1, 10)
    e.NewValues("Title") = "Sales Representative"
End Sub