Input Validation
- 2 minutes to read
You can validate new data before saving it to a data source. Likewise, you can ensure that invalid data is not saved to a data source and related errors are clearly displayed.
Note
When you use a custom CellTemplate, input validation is supported only if the template contains a BaseEdit class descendant that is declared as demonstrated in the following topic: Custom In-Place Cell Editors.
GridControl Level
The GridControl raises special events that allow you to validate modified cells and rows:
Data Level
You can validate data based on interfaces and attributes:
Check Whether the Grid Contains Validation Errors
The GridControl includes the following properties that allow you to check whether the grid has validation errors:
- The DataViewBase.HasValidationError property discloses whether the GridControl contains validation errors that do not allow users to post changes to a data source. Use this property when you implement validation at the GridControl level.
- The DataViewBase.HasErrors property (along with the DataViewBase.ErrorsWatchMode property) discloses whether the GridControl contains validation errors posted to a data source. Use this property when you implement validation at the data level.