THEMES
THEME SETTINGS

Grid View - Editing Edit Form Template

# 
Product Name 
Category 
Quantity Per Unit 
Unit Price 
Units In Stock 
Discontinued 
EditNewDeleteChaiBeverages10 boxes x 20 bags$18.0039
 ChangBeverages24 - 12 oz bottles$19.0017
v
-
+
-
+
+
-
Update
Cancel
EditNewDeleteAniseed SyrupCondiments12 - 550 ml bottles$10.0013
EditNewDeleteChef Anton's Cajun SeasoningCondiments48 - 6 oz jars$22.0053
EditNewDeleteChef Anton's Gumbo MixCondiments36 boxes$21.350
EditNewDeleteGrandma's Boysenberry SpreadCondiments12 - 8 oz jars$25.00120
EditNewDeleteUncle Bob's Organic Dried PearsProduce12 - 1 lb pkgs.$30.0015
EditNewDeleteNorthwoods Cranberry SauceCondiments12 - 12 oz jars$40.006
EditNewDeleteMishi Kobe NikuMeat/Poultry18 - 500 g pkgs.$97.0029
EditNewDeleteIkuraSeafood12 - 200 ml jars$31.0031
Page 1 of 8 (77 items)Prev12345678Next

MVC Grid View allows you to provide a custom edit mode layout by creating an appropriate template for particular edited row cells or an entire Edit Form.

This demo describes how a template for the grid's Edit Form can be defined using the SetEditFormTemplateContent method. Within a template, custom label-editor pairs and Update/Cancel buttons are explicitly created using helpers from DevExpress Data Editors extensions (such as the Label, TextBox, ComboBox, SpinEdit, Button, etc.).

Editors used within a template are customized in the following simple manner: they are bound to corresponding model data fields (using the Bind method), are named according to these fields (using the Name property), and their ability to automatically visualize model errors when validation fails is enabled (using the ShowModelErrors property).

Editors bind to values of the model's currently edited data object. Note that this object is passed into a template either automatically (as a template container's DataItem property - when a grid row is just switched to edit mode) or manually (as a ViewData data object passed from a controller - when data modifications cannot be accomplished due to input validation fail and it is required to return the edited data object back to the view's Edit Form without losing user changes). To correctly transfer values from DevExpress editors back to corresponding data model fields, the DevExpressEditorsBinder model binder is used within controller actions.

Buttons that represent the Update and Cancel links are customized so that their Text properties are defined ("Update" and "Cancel" texts) and the Click client events are handled to call the grid's respective client methods - UpdateEdit and CancelEdit.

Version: v2017 vol 1.3
Copyright © 2006-2017 Developer Express Inc
Your Next Great MVC App Starts Here

Get started today and download your 30-day trial of DevExpress MVC Extensions (includes 30 days of free technical support).

All demos ship with full source code and are included in the DevExpress MVC distribution. Refer to the Demos and Sample Applications topic to learn more.

DevExpress MVC Extensions ship as part of DevExpress Universal, DXperience and ASP.NET Subscriptions and are backed by a 60 day unconditional money-back guarantee.
To learn more and obtain pricing information, visit the Compare Features and Pricing webpage. For immediate assistance, contact us by Email at info@devexpress.com or by phone at +1 (818) 844-3383 between 7:30am and 4:30pm Pacific Time.