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

Interfaces-Based Validation

  • 2 minutes to read

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

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.

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.

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.

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 (ErrorIcon_Critical) within cells with the descriptions displayed as tooltips.