Skip to main content
A newer version of this page is available. .

Error Notification

  • 2 minutes to read

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 (ErrorIcon_Critical) 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, IDataErrorInfo, or INotifyDataErrorInfo interface.

Implementing the Error Notifications for a Custom Data Source

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

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

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

INotifyDataErrorInfo

Starting from v18.1, the GridControl checks for and reports errors that are raised by a data source that implements INotifyDataErrorInfo. Refer to the DataViewBase.ValidatesOnNotifyDataErrors topic for more information.