[Expand]General Information
[Expand]WinForms Controls
[Collapse]ASP.NET Controls and MVC Extensions
 [Expand]What's Installed
 [Expand]Common Concepts
 [Expand]ASP.NET WebForms Controls
 [Collapse]ASP.NET MVC Extensions
  [Expand]Product Information
  [Expand]Getting Started
  [Expand]Common Concepts
  [Collapse]Grid View
    Main Features
    [Expand]Binding to Data
    [Expand]Data Representation Basics
    [Expand]Data Shaping and Manipulation
    [Expand]Focus and Navigation
    [Collapse]Data Editing and Validation
      Data Editing
      Edit Modes
      Edit Form
      Batch Edit
      Validate Data
      Initializing New Rows
   [Expand]Visual Elements
   [Expand]Member Tables
  [Expand]Tree List
  [Expand]Card View
  [Expand]Pivot Grid
   Rich Text Editor
  [Expand]Site Navigation and Layout
  [Expand]HTML Editor
  [Expand]Vertical Grid
  [Expand]Data Editors
  [Expand]Docking and Popups
  [Expand]File Management
  [Expand]Data and Image Navigation
  [Expand]Multi-Use Site Extensions
  [Expand]Spell Checker
  [Expand]Query Builder
 [Expand]Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Report and Dashboard Server
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

Validate Data

The DevExpress ASP.NET MVC GridView extension and DevExpress ASP.NET MVC Data Editors support a model-based data validation approach. According to this approach, you should use jQuery validation and decorate model class properties with the DataAnnotations attributes.


Refer to the following topics to get more information about validation approaches:

This topic illustrates how to validate data in the DevExpress ASP.NET MVC GridView extension.

Expanded Add validation rules to the model class

Add the required DataAnnotation attributes to the corresponding model class properties to specify validation rules for the model fields.

See also: How data annotations for ASP.NET MVC validation work.

Expanded Enable Server-Side Validation

When users submit data, the grid sends a callback to the server and calls an appropriate action method. In the action method, use the ModelStateDictionary.IsValid property to get the user input validation state. If the user input is valid, the grid adds/updates data to the data source. Otherwise, the grid displays an error message near the grid editor that contains invalid data.

Controller code:

Expanded Enable Unobtrusive Client Validation

Unobtrusive client validation allows you to validate model fields without sending a callback to the server.


Include the jquery-3...min.js, jquery.validate.min.js and jquery.validate.unobtrusive.min.js JavaScript libraries in the order they are specified in the following code sample to enable the client-side validation.

Use the following code samples to include the required JavaScript references:

  • Applies the client-side validation to a single web page.

  • Applies the client-side validation to all pages in a project (Web.Config file).

  • Applies the client-side validation to a specific view.

    Partial View:



    For the GridView, specify the IEnumerable<T> model as the GridView's partial view model.

Expanded Display Validation Error Messages

For Server-Side Validation

The ASP.NET MVC GridView extension allows you to display error messages in the edit form or error row.

Use the MVCxGridViewEditingSettings.ShowModelErrorsForEditors property to specify whether the grid displays validation error messages for data editors in the edit form.

The grid displays an error message based on the ModelState object. Use the AddModelError method to specify custom error text for the required column in the Controller code.

For Client-Side Validation

Use the DevExpress ASP.NET MVC Data Editors' ShowModelErrors property to specify whether the grid displays error messages in editors when validation fails. The ValidationSettings.ErrorDisplayMode property specifies whether the error message contains an error text, icon and tooltip.

ErrorDisplayMode property value




An error message includes text and an image.


An error message contains only an image. The image's tooltip displays the error text.


An error message contains only text.


The grid displays an error frame around an editor.

Is this topic helpful?​​​​​​​