[Expand]General Information
[Expand]WinForms Controls
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Collapse]WPF Controls
 [Expand]What's Installed
 [Expand]Common Concepts
 [Expand]MVVM Framework
 [Collapse]Controls and Libraries
  [Collapse]Data Grid
   [Expand]Getting Started
   [Expand]Implementation Details
   [Expand]Grid View Data Layout
   [Expand]Binding to Data
   [Expand]Master-Detail Data Representation
   [Collapse]Data Editing and Validation
     Edit Form
     New Item Row
    [Expand]Inplace Editors
    [Expand]Editing in Code
    [Collapse]Input Validation
      Cell Validation
      Row Validation
      Error Notification
      Attributes-Based Validation
    [Expand]Clipboard Management
     Moving Nodes in TreeList
   [Expand]Filtering and Searching
   [Expand]Data Summaries
   [Expand]Paging and Scrolling
   [Expand]Focus and Navigation
   [Expand]Conditional Formatting
   [Expand]Appearance Customization
   [Expand]MVVM Enhancements
   [Expand]Printing and Exporting
   [Expand]End-User Interaction
   [Expand]Performance Improvement
   [Expand]Design-Time Features
   [Expand]Visual Elements
   [Expand]End-User Capabilities
  [Expand]Ribbon, Bars and Menu
  [Expand]Charts Suite
  [Expand]Pivot Grid
  [Expand]Rich Text Editor
  [Expand]Tree List
  [Expand]Gauge Controls
  [Expand]Map Control
  [Expand]Layout Management
  [Expand]Windows Modern UI
  [Expand]Data Editors
  [Expand]Navigation Controls
  [Expand]Spell Checker
  [Expand]Property Grid
  [Expand]PDF Viewer
  [Expand]TreeMap Control
  [Expand]Diagram Control
  [Expand]Windows and Utility Controls
   Dialogs, Notifications and Panels
  [Expand]Scheduler (legacy)
 [Expand]Scaffolding Wizard
  Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Report and Dashboard Server
[Expand]eXpressApp Framework
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

Attributes-Based Validation

The GridControl supports DataAnnotations attributes that specify data validation rules (to use data annotation attributes, reference the System.ComponentModel.DataAnnotations assembly). These attributes are listed in the table below.

Validation Attribute Description
System.ComponentModel.DataAnnotations.CustomValidationAttribute Uses a custom method for validation.
System.ComponentModel.DataAnnotations.DataTypeAttribute Specifies a particular type of data, such as an e-mail address or phone number.
System.ComponentModel.DataAnnotations.EnumDataTypeAttribute Ensures that the value exists in an enumeration.
System.ComponentModel.DataAnnotations.RangeAttribute Designates minimum and maximum constraints.
System.ComponentModel.DataAnnotations.RegularExpressionAttribute Uses a regular expression to determine valid values.
System.ComponentModel.DataAnnotations.RequiredAttribute Specifies that a value must be provided.
System.ComponentModel.DataAnnotations.StringLengthAttribute Designates maximum and minimum number of characters.

By default, the grid displays error icons () within cells with invalid values, and provides error descriptions displayed as tooltips (see the image below). In this instance, the cell focus cannot be moved to another cell until the cell's value is corrected.

The following validation options allow you to override default behavior.

Validation Attribute Description



If set to false, hides validation errors specified via DataAnnotations attributes.
DataViewBase.AllowCommitOnValidationAttributeError If set to true, posts the invalid value to a data source and allows the cell focus to be moved to another cell.

The attributes-based validation does not work when using the ColumnBase.Binding property.

Refer to the How to: Implement Attributes-Based Validation example to learn more.

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