This demo illustrates the Grid View's built-in data editing functionality.
To enable data editing operations, the grid's KeyFieldName property must be specified. For each allowed data operation (such as inserting, updating or deleting), provide an associated controller action that will apply data changes to Model and return the grid's partial view. You can reference these controller actions by their names using the AddNewRowRouteValues, UpdateRowRouteValues, and DeleteRowRouteValues properties. Note that in actions that handle update and insert operations, you can obtain the edited object using our specific DevExpressEditorsBinder model binder. In the actions handling delete operations, you can get the key value of the deleted row.
To allow end-users to manipulate grid data, add a command column to the grid's column collection and specify which commands (New, Edit, Delete, Update, Cancel) can be used by end-users. To switch a grid row to edit mode, end-users should be allowed to click the Edit command.
The following list highlights built-in edit modes available for the Grid View, from the simplest to the most sophisticated (use the grid's SettingsEditing.Mode property to specify edit mode):
When a row is switched to edit mode, its cells display appropriate editors.
When a row is switched to edit mode, an edit form appears under or instead of the edited row.
Edit Form displays label-editor pairs that correspond to data columns, and the Update/Cancel commands that allow end-users to save or discard the changes made. The EditFormSettings property of data columns contains different settings to arrange label-editor pairs. This provides you with a flexible data editor arrangement mechanism. The default layout of the Edit Form is generated automatically.
Popup Edit Form
When a row is switched to edit mode, Edit Form is displayed as a popup window, which can be dragged and used in modal mode, if required.
An error is displayed next to the individual form editors. However, an additional error message can be displayed below the edit form using the SetEditErrorText method.