Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[Expand]Welcome to DevExpress .NET Documentation
[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]Common Concepts
 [Expand]MVVM Framework
 [Collapse]Controls and Libraries
  [Expand]Windows and Utility Controls
   Dialogs, Notifications and Panels
   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
     Data Editing Overview
     Edit Form
     New Item Row
    [Expand]Inplace Editors
    [Collapse]Input Validation
      Cell Validation
      Row Validation
      Validating Nodes and Node Cells
      Error Notification
      Attributes-Based Validation
      Examples
    [Expand]Editing in Code
    [Expand]Clipboard Management
     Moving Nodes in TreeList
   [Expand]Grouping
   [Expand]Selection
   [Expand]Filtering and Searching
   [Expand]Sorting
   [Expand]Data Summaries
   [Expand]Data Scrolling
   [Expand]Focus and Navigation
   [Expand]Conditional Formatting
   [Expand]Drag-and-Drop
   [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]Diagram Control
  [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]Document Server
[Expand]Reporting
[Expand]Report Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

Error Notification

Expanded Overview

If the grid is bound to System.Data.DataView or System.Data.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 System.Data.DataRow.SetColumnError method. The grid indicates these errors by displaying error icons () within cells with the descriptions displayed as tooltips.

To support error notifications for a custom data source (IList, ITypedList, IListSource, IBindingList, etc.), objects that represent records in a data source should implement the IDXDataErrorInfo or System.ComponentModel.IDataErrorInfo interface.

This document describes how to implement error notifications for a custom data source using IDXDataErrorInfo.

Expanded Implementing the Error Notifications for a Custom Data Source

When binding a grid to a custom data source (e.g. data created at runtime), you create two classes:

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

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.

  • 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).

Expanded Example: How to Validate Rows and Indicate Errors

Show Me

A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=E1593.

This example shows how to check the validity of data entered by end-users into a data row. The GridViewBase.ValidateRow and GridViewBase.InvalidRowException events are handled to validate the focused row's data, and if it is invalid, prevent the row focus from being moved to another row until invalid values are corrected.

Since the Task class doesn't support error notifications, it implements the IDXDataErrorInfo interface, providing two members to get error descriptions for the entire row and for individual cells (data source fields). This displays error icons within cells with invalid values. Pointing to such an error icon displays a tooltip with an error description.

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