New to Telerik UI for ASP.NET MVC? Download free 30-day trial

ASP.NET MVC Grid Custom Validator Editing

Loading Demo...
  • EXAMPLE
  • VIEW SOURCE
editing_custom_validation.cshtml
Editing_Custom_ValidationController.cs
ProductService.cs

Also available for:

CLIENT-SIDE API SERVER-SIDE API

Description

Some scenarios require the Telerik UI for ASP.NET MVC Data Grid not only to visualize data in a table structure, but also to support editing and validation before users save changes.

The Telerik UI for ASP.NET MVC Grid allows you to implement CRUD data-editing operations by setting its data source.

To enable the data-editing capabilities of the component:

  1. Set the Editable configuration property of the Grid—.Editable(editable => editable.Mode(GridEditMode.InCell)).
  2. Declare the field definitions of the Data Grid through the Model configurator.
  3. Configure the DataSource of the Data Grid for performing CRUD data operations by defining its Read, Create, Update, and Destroy methods.
  4. To allow the insertion of new Data Grid records, enable the relevant option in the toolbar of the component—.ToolBar(toolbar => toolbar.Create()).
  5. To allow the deletion of Data Grid items, include a Delete command column.

This demo shows how to define a custom validation rule by setting the CustomValidationProductViewModel model and the productnamevalidation function. You can force a check for a first capital letter on the Product Name column when you edit the value in it.

For more information about the editing capabilities, refer to the official Telerik UI for ASP.NET MVC Data Grid product documentation on the available data-editing approaches.

Additional Apps

This Grid example is part of a unique collection of hundreds of ASP.NET MVC demos, with which you can see all Telerik ASP.NET MVC components and their features in action. View the source code of the demos from the library or directly adapt, and edit them and their theme appearance in the ThemeBuilder.

Support & Learning Resources

Additional Resources