Data annotation means adding meaningful metadata tags to the classes and other objects, making it easier to bridge the gap between models and views by performing data validation and displaying appropriate messages to the end users. For example, you may use data annotations to specify how items should be formatted, what their captions should be, whether they should be editable or not.
FlexGrid supports multiple data annotation attributes used for customizing data classes, displaying data from source, and setting validation rules. To use the attributes in your project, you need to add a reference to the System.ComponentModel.DataAnnotations assembly and then add the attributes to your data objects in the code.
Listed below are some of the major annotation attributes that are supported in FlexGrid control. Cilck here for complete list of DataAnnotation attributes.
Attribute Name | Functionality in FlexGrid |
---|---|
Association | Specifies that an entity member represents a data relationship, such as a foreign key relationship. |
Display | Provides a general-purpose attribute that lets you specify localizable strings for types and members of entity partial classes. |
DisplayFormat | Specifies how data fields are displayed and formatted by ASP.NET Dynamic Data. |
DisplayColumn | Specifies the column that is displayed in the referred table as a foreign-key column. |
Editable | Indicates whether a data field is editable. |
Key | Denotes one or more properties that uniquely identify an entity. |
Validation
|
The data annotation validation attributes are used as validation rules in FlexGrid operations. |
The following code example shows how data annotation feature works in WinForms FlexGrid control.