Attributes-Based Validation
- 2 minutes to read
DXGrid for Silverlight supports DataAnnotations attributes that specify data validation rules (to use data annotation attributes, reference the System.ComponentModel.DataAnnotations assembly). These attributes are listed in the table below.
Validation Attribute | Description |
---|---|
Custom |
Uses a custom method for validation. |
Data |
Specifies a particular type of data, such as an e-mail address or phone number. |
Enum |
Ensures that the value exists in an enumeration. |
Range |
Designates minimum and maximum constraints. |
Regular |
Uses a regular expression to determine valid values. |
Required |
Specifies that a value must be provided. |
String |
Designates maximum and minimum number of characters. |
By default, the grid displays error icons () within cells with invalid values, and provides error descriptions displayed as tooltips (see the image below). In this instance, the cell focus cannot be moved to another cell until the cell's value is corrected.
The following validation options allow you to override default behavior.
Validation Attribute | Description |
---|---|
If set to false, hides validation errors specified via Data | |
If set to true, posts the invalid value to a data source and allows the cell focus to be moved to another cell. |
NOTE
The attributes-based validation does not work when using the Column