Skip to main content
All docs
V25.1

DevExpress v25.1 Update — Your Feedback Matters

Our What's New in v25.1 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

Step 5: Enable Data Edit Operations

You can allow users to edit data in the GridControl.

Virtual Source Tutorial - Editing

Explore the full source code in the following example and demo:

View Example: WPF Data Grid - Bind to InfiniteAsyncSource Run Demo: Infinite Scrolling Source

#Implementation Details

  1. Enable the ColumnBase.AllowEditing property for the columns that users can edit.

  2. Set the TableView.ShowUpdateRowButtons property to OnCellEditorOpen / OnCellValueChange to enable Edit Entire Row mode.

  3. Create a task that uses the Issues Service‘s UpdateRowAsync method to save changes to the data source.

  4. Create an UpdateIssue command in the ViewModel. To save changes asynchronously, assign the task to the RowValidationArgs.ResultAsync property.

  5. Bind the command to the GridViewBase.ValidateRowCommand.

xml
<dxg:GridControl>
    <dxg:GridControl.Columns>
        <dxg:GridColumn FieldName="Subject" IsSmart="True" AllowEditing="True"/>
        <dxg:GridColumn FieldName="User" IsSmart="True" AllowEditing="True"/>
        <dxg:GridColumn FieldName="Created" IsSmart="True" AllowEditing="True"/>
        <dxg:GridColumn FieldName="Votes" IsSmart="True" AllowEditing="True"/>
        <dxg:GridColumn FieldName="Priority" IsSmart="True" AllowEditing="True"/>
    </dxg:GridControl.Columns>
    <dxg:GridControl.View>
        <dxg:TableView ShowUpdateRowButtons="OnCellEditorOpen"
                       ValidateRowCommand="{Binding UpdateIssueCommand}"/>
    </dxg:GridControl.View>
</dxg:GridControl> 
C#
[Command]
public void UpdateIssue(RowValidationArgs args) {
    args.ResultAsync = UpdateIssueAsync((IssueData)args.Item);
}

static async Task<ValidationErrorInfo> UpdateIssueAsync(IssueData issue) {
    await IssuesService.UpdateRowAsync(issue);
    return null;
}