Back to Devexpress

Data Annotation Attributes

aspnet-400998-components-site-navigation-and-layout-form-layout-concepts-data-annotation-attributes.md

latest2.8 KB
Original Source

Data Annotation Attributes

  • Jul 19, 2024
  • 2 minutes to read

DevExpress ASP.NET ASPxFormLayout control supports data annotation attributes. You can apply these attributes to the class to specify validation rules and data display mode, set relationships between classes, etc.

Declaration

csharp
class TestClass {        
    [Display(Name = "Check it")]
    [CheckBoxRequired(ErrorMessage = "Error text")]
    public bool CheckBoxField { get; set; }
}
aspx
<dx:ASPxFormLayout runat="server" ID="fl">
    <Items>
        <dx:LayoutItem FieldName="CheckBoxField">
            <LayoutItemNestedControlCollection>
                <dx:LayoutItemNestedControlContainer>
                    <dx:ASPxCheckBox runat="server" />
                </dx:LayoutItemNestedControlContainer>
            </LayoutItemNestedControlCollection>
        </dx:LayoutItem>
        ...
    </Items>
</dx:ASPxFormLayout>

Data Display Attributes

Common data attributes supported by DevExpress data controls are as follows.

Data Type Attributes

  • DataTypeAttribute - Specifies the type of a data field’s value. Supported for DataType.Currency and DataType.Password types.

Validation Attributes