Back to Devexpress

Lesson 3 - Post Changes to a Database

wpf-96471-controls-and-libraries-data-grid-getting-started-code-lesson-3-post-changes-to-a-database.md

latest2.0 KB
Original Source

Lesson 3 - Post Changes to a Database

  • Jun 06, 2023
  • 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.

  1. Set the TableView.ShowUpdateRowButtons property to OnCellEditorOpen or OnCellValueChange. 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 GridControl saves changes locally and does not post them to a database. To save changes to the database, create a ValidateAndSave command in the View Model. The command calls the data context’s SaveChanges method:

  3. Bind the ValidateAndSave command to the GridViewBase.ValidateRowCommand property. The GridControl executes this command after a user clicks the Update button:

You can use the approach demonstrated in this tutorial to implement other CRUD operations. Refer to the following help topic for more information: CRUD Operations in a Data-Bound Grid.

See Also

Lesson 4 - Sort, Group, Filter Data

Lesson 5 - Display Summaries

Edit Entire Row