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.
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.
Local Copy of this Demo
To inspect the source code for this demo on your machine, you must first install our components via the DevExpress Component Installer.
You can open a local copy of this online demo directly from this webpage (if using v20.2.8, 21.1.4 or higher).
The source code files for this demo are installed (by default) in the following directory:
Open CS Solution
\Users\Public\Documents\DevExpress Demos XX.X\Components\ASP.NET\CS\MVCxGridViewDemos