Skip to main content
A newer version of this page is available. .
Tab

ASPxGridView.RowInserted Event

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

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v20.2.dll

NuGet Package: DevExpress.Web

Declaration

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.

Remarks

End-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, end-users must click the Update command.

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

Note

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.

Example

To focus the newly inserted row, it is necessary to know the keyValue of this row. You can get the value by handling the RowInserted event, which is raised after a new row has been added to the ASPxGridView's data source.

View Example

<dx:ASPxGridView ID="grid" runat="server" AutoGenerateColumns="False" DataSourceID="XpoDataSource1"
    KeyFieldName="Oid" OnRowInserted="grid_RowInserted">
    <SettingsPager PageSize="5" />
    <SettingsBehavior AllowFocusedRow="true" />
    <Columns>
        <dx:GridViewCommandColumn VisibleIndex="0" ShowEditButton="True" ShowNewButton="True"/>
        <dx:GridViewDataTextColumn FieldName="Oid" ReadOnly="True" VisibleIndex="1" SortIndex="0"
            SortOrder="Ascending">
            <EditFormSettings Visible="False" />
        </dx:GridViewDataTextColumn>
        <dx:GridViewDataTextColumn FieldName="CompanyName" VisibleIndex="3">
        </dx:GridViewDataTextColumn>
        <dx:GridViewDataTextColumn FieldName="ContactName" VisibleIndex="4">
        </dx:GridViewDataTextColumn>
        <dx:GridViewDataTextColumn FieldName="Country" VisibleIndex="5">
        </dx:GridViewDataTextColumn>
    </Columns>
</dx:ASPxGridView>
<dx:XpoDataSource ID="XpoDataSource1" runat="server" TypeName="Customer">
</dx:XpoDataSource>
See Also