[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
  Prerequisites
 [Expand]What's Installed
 [Expand].NET Core 3 Support
 [Expand]Common Concepts
 [Expand]MVVM Framework
 [Collapse]Controls and Libraries
   Reporting
  [Collapse]Data Grid
   [Expand]Getting Started
   [Expand]Implementation Details
   [Expand]Views
   [Expand]Grid View Data Layout
   [Expand]Binding to Data
   [Expand]Master-Detail Data Representation
   [Collapse]Data Editing and Validation
     Add and Remove Rows
    [Expand]Modify Cell Values
    [Collapse]Input Validation
      Cell Validation
      Row Validation
      Interfaces-Based Validation
      Attributes-Based Validation
    [Expand]Clipboard Management
     Examples
   [Expand]Grouping
   [Expand]Filtering and Searching
   [Expand]Sorting
   [Expand]Data Summaries
   [Expand]Paging and Scrolling
   [Expand]Focus, Navigation, Selection
   [Expand]Drag-and-Drop
   [Expand]Conditional Formatting
   [Expand]Appearance Customization
   [Expand]MVVM Enhancements
   [Expand]Printing and Exporting
   [Expand]End-User Interaction
   [Expand]Miscellaneous
   [Expand]Performance Improvement
   [Expand]Design-Time Features
   [Expand]Visual Elements
   [Expand]End-User Capabilities
   [Expand]Examples
  [Expand]Ribbon, Bars and Menu
  [Expand]Charts Suite
  [Expand]Pivot Grid
  [Expand]Scheduler
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]Tree List
  [Expand]Gauge Controls
  [Expand]Map Control
  [Expand]Layout Management
  [Expand]Windows Modern UI
  [Expand]Printing-Exporting
  [Expand]Data Editors
  [Expand]Navigation Controls
  [Expand]Spell Checker
  [Expand]Property Grid
  [Expand]PDF Viewer
  [Expand]TreeMap Control
  [Expand]Gantt Control
  [Expand]Diagram Control
  [Expand]Windows and Utility Controls
   Dialogs, Notifications and Panels
  [Expand]Scheduler (legacy)
 [Expand]Scaffolding Wizard
 [Expand]Localization
  Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Reporting
[Expand]Report and Dashboard Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

Interfaces-Based Validation

You can support error notifications for a custom data source (IList, ITypedList, IListSource, IBindingList, etc.).

When binding a grid to a custom data source (for example, data created at runtime), you create two classes:

  • The class that represents the data source. This class implements one of the interfaces (IList, IListSource, ITypedList, IBindingList), and provides access to the collection of records.
  • The class that implements a single record in a data source.

Objects that represent records in a data source should implement the IDXDataErrorInfo, System.ComponentModel.IDataErrorInfo, or System.ComponentModel.INotifyDataErrorInfo interface.

Expanded IDataErrorInfo

To support error notifications, the class encapsulating a single record must implement the IDXDataErrorInfo interface. This interface provides two methods, that when implemented, get errors for the entire row and for individual cells (data source fields). As a result, the grid automatically displays error icons within cells with invalid values. Pointing to such an error icon displays a tooltip with an error description.

Expanded IDXDataErrorInfo

  • IDXDataErrorInfo.GetPropertyError - When implemented by a class, returns information on an error associated with the specified property (data field) of a data object.
  • IDXDataErrorInfo.GetError - When implemented by a class, returns information on an error associated with a data object (row).

Refer to the How to: Validate Data Rows and Indicate Errors example to learn more how to use IDXDataErrorInfo.

Expanded INotifyDataErrorInfo

Starting from v18.1, the GridControl checks for and reports errors that are raised by a data source that implements System.ComponentModel.INotifyDataErrorInfo.

When the INotifyDataErrorInfo.GetErrors method returns a collection with multiple values, the GridControl displays the first error from this collection. If this collection contains a custom object, an error tooltip contains a value that the ToString (see System.Object) method returns.

To disable this validation type, set the DataViewBase.ValidatesOnNotifyDataErrors property to false.

Tip

If the GridControl is bound to DataView or DataTable, you can set errors for any cell within any row using methods provided by the data source. To set an error for the required cell, call the DataRow.SetColumnError method. The GridControl indicates these errors by displaying error icons () within cells with the descriptions displayed as tooltips.

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