Skip to main content

ASPxGridView.RowInserted Event

Fires after a new row has been added to the ASPxGridView.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v23.1.dll

NuGet Package: DevExpress.Web


public event ASPxDataInsertedEventHandler RowInserted

Event Data

The RowInserted event's data class is ASPxDataInsertedEventArgs. The following properties provide information specific to this event:

Property Description
AffectedRecords Gets the number of records affected by the update operation. Inherited from ASPxDataBaseUpdatedEventArgs.
Exception Gets the exception (if any) that was raised during the update operation. Inherited from ASPxDataBaseUpdatedEventArgs.
ExceptionHandled Gets or sets whether an exception raised during the update operation was handled in the event handler. Inherited from ASPxDataBaseUpdatedEventArgs.
NewValues Gets a dictionary that contains the values of the non-key field name/value pairs in the row to be inserted.


Users can create new rows by clicking the New command. To create rows in code, use the ASPxGridView.AddNewRow method. To save the newly created row, users must click the Update command.

To cancel the insert operation, handle the ASPxGridView.RowInserting event.


The RowInserted event fires even though an exception occurs during the data update operation. Use the ASPxDataBaseUpdatedEventArgs.Exception and ASPxDataBaseUpdatedEventArgs.ExceptionHandled argument properties to determine whether or not any exception occurs during the corresponding action, and handle it if you wish.


The following example demonstrates how to handle the grid’s RowInserted event to focus the newly inserted row:

View Example: How to focus the newly inserted row

After the grid adds a new row to the data source, you can get the row’s key value in the grid’s server-side RowInserted event. To focus the newly inserted row, call the grid’s FindVisibleIndexByKeyValue(Object) method to get the row’s visible index and assign that index to the grid’s FocusedRowIndex property:

protected void grid_RowInserted (object sender, ASPxDataInsertedEventArgs e) {
    object newKey = null;
    if (e.AffectedRecords == 1) {
        ICollection objects = uof.GetObjectsToSave();
        if (objects != null && objects.Count == 1) {
            IEnumerator enumeration = objects.GetEnumerator();
            Customer obj = (Customer)enumeration.Current;
            newKey = obj.Oid;
    grid.FocusedRowIndex = grid.FindVisibleIndexByKeyValue(newKey);
See Also