You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: blazor/datagrid/data-annotation.md
+10-10Lines changed: 10 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,19 +1,19 @@
1
1
---
2
2
layout: post
3
3
title: Data Annotation in Blazor DataGrid | Syncfusion
4
-
description: Learn how to achieve data validation with data annotations in the Syncfusion Blazor DataGrid component.
4
+
description: Learn how to use Data Annotations for validation and column metadata in Syncfusion Blazor DataGrid, including enum display and CRUD form validation.
5
5
platform: Blazor
6
6
control: DataGrid
7
7
documentation: ug
8
8
---
9
9
10
10
# Data Annotation in Blazor DataGrid
11
11
12
-
Data Annotations are used to define validation rules for model classes or properties, ensuring that data entered into an application conforms to the expected format and meets specific criteria. They also enable the display of appropriate error messages to end users.
12
+
Data Annotations define validation and display rules on model classes or properties, ensuring that user input conforms to expected formats and constraints while providing meaningful error messages.
13
13
14
-
In the Syncfusion<supstyle="font-size:70%">®</sup> Blazor DataGrid, Data Annotations are leveraged to automatically map these validation rules to the corresponding [GridColumn](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.GridColumn.html)properties. This integration provides seamless data validation during editing operations within the Grid.
14
+
In the Syncfusion<supstyle="font-size:70%">®</sup> Blazor DataGrid, Data Annotations are automatically mapped to corresponding [GridColumn](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.GridColumn.html)behaviors, enabling seamless validation during editing operations within the Grid.
15
15
16
-
To enable Data Annotations for validation in a Grid, you need to refer the **System.ComponentModel.DataAnnotations** namespace in your Blazor application. Once enabled, the Grid automatically uses the data annotations applied to your model class properties to perform data validation.
16
+
To enable Data Annotation-based validation in the grid, reference the **System.ComponentModel.DataAnnotations** namespace in the Blazor app. When bound to a model (via TValue and DataSource), the grid applies the attributes defined on model properties during CRUD operations.
17
17
18
18
The following table lists the data annotation attributes supported in the Grid:
19
19
@@ -35,7 +35,7 @@ The following table lists the data annotation attributes supported in the Grid:
35
35
| Key | Key | Marks a column as the primary key in the Grid |
36
36
| Validation Attributes:<br><br>1. RequiredAttribute<br>2. StringLengthAttribute<br>3. RangeAttribute<br>4. RegularExpressionAttribute<br>5. MinLengthAttribute<br>6. MaxLengthAttribute<br>7. EmailAddressAttribute<br>8. CompareAttribute<br> || These validation attributes are used as `validation rules` in Grid CRUD operations |
37
37
38
-
> The Syncfusion<supstyle="font-size:70%">®</sup> Blazor DataGrid property takes precedence over data annotation attributes. For example, when both the DisplayName attribute and `HeaderText` are assigned to a field in the Grid model class for a specific column, the `HeaderText` value will be prioritized and displayed in the Grid header.
38
+
> The Syncfusion<supstyle="font-size:70%">®</sup> Blazor DataGrid property takes precedence over data annotation attributes. For example, when both the Display attribute and `HeaderText` are assigned to a field in the model for a specific column, the `HeaderText` value will be prioritized and shown in the grid header.
39
39
40
40
The following sample code demonstrates how to use data annotations in the Grid:
41
41
@@ -50,7 +50,7 @@ The following sample code demonstrates how to use data annotations in the Grid:
The following image shows how Data Annotations are applied to Grid columns in a Blazor application:
155
+
The following image shows how Data Annotations are applied to grid columns in a Blazor application:
156
156
157
157

158
158
159
-
> The **Verified** column displays the `Enum` member using the `Display` attribute name, enhancing user experience by rendering a human-readable label instead of the raw enum value.
159
+
> The **Verified** column displays the Enum member using the `Display` attribute name, improving readability by showing a user-friendly label instead of the raw enum value.
160
160
161
-
> You can refer to our [Syncfusion<supstyle="font-size:70%">®</sup> Blazor DataGrid](https://www.syncfusion.com/blazor-components/blazor-datagrid) feature tour page for its features. You can also explore our [Syncfusion<supstyle="font-size:70%">®</sup> Blazor DataGrid example](https://blazor.syncfusion.com/demos/datagrid/overview?theme=bootstrap5) to understand how to present and manipulate data.
161
+
N> Refer to the [Blazor DataGrid](https://www.syncfusion.com/blazor-components/blazor-datagrid) feature tour for a broad overview. Explore the [Blazor DataGrid example](https://blazor.syncfusion.com/demos/datagrid/overview?theme=bootstrap5) to understand data presentation and manipulation.
0 commit comments