Skip to main content
All docs

Lesson 3 - Post Changes to a Database

  • 2 minutes to read

This tutorial demonstrates how to edit data within the GridControl and save changes to the database. The tutorial is based on Lesson 2.

The Items Source Wizard adds data posting functionality when you enable the CRUD (Create, Read, Update, Delete) options.

Items Source Wizard - Settings

The Items Source Wizard: generates the following code:

  1. The TableView.ShowUpdateRowButtons property is set to OnCellEditorOpen. This turns on an edit mode that allows users to edit an entire row and then submit or cancel all changes at once:

  2. The commands are generated at runtime from the methods with the attribute Command attached to them. A generated command name follows the [MethodName]Command pattern.

    The ValidateRow command saves newly added rows and changes to the existing ones back to the database:

    public void ValidateRow(RowValidationArgs args) {
        var item = (Order)args.Item;
        if (args.IsNewItem)

    The ValidateRowDeletion command saves row deletion back to the database:

    public void ValidateRowDeletion(ValidateRowDeletionArgs args) {
        var item = (Order)args.Items.Single();

    The DataSourceRefresh command fetches changes from the database and updates the grid’s content:

    public void DataSourceRefresh(DataSourceRefreshArgs args) {
        _ItemsSource = null;
        _Context = null;

    The TableView‘s properties include bindings to the generated commands:

    <dxg:GridControl ItemsSource="{Binding Orders}">
        <!-- ... -->
            <dxg:TableView NewItemRowPosition="Top"
                ValidateRowCommand="{Binding ValidateRowCommand}"
                ValidateRowDeletionCommand="{Binding ValidateRowDeletionCommand}"
                DataSourceRefreshCommand="{Binding DataSourceRefreshCommand}"/>
See Also