DataGrid / Editing / Custom Validation

Blazor DataGrid Example - Custom Validation

Loading Syncfusion Blazor Server Demos…

1 of 2 pages (20 items)

This sample demonstrates how to implement custom validation in the DataGrid using data annotations.

The Blazor DataGrid supports custom validation through data annotations. To use custom validation, import the System.ComponentModel.DataAnnotations namespace and create a custom validation class that extends ValidationAttribute. Override the IsValid method to implement your validation logic.

In this demo, the following custom validations are implemented:

  • A CustomValidationFreight class validates that the Freight value is between 1 and 1000.
  • A CustomValidationEmployeeID class validates that the EmployeeID value is greater than 0.

When users enter invalid data, error messages are displayed automatically. Try adding a new record with empty or invalid values to see the validation messages.

For more detailed information about custom validation, refer to the custom validation documentation.

Transform your Blazor web apps today with Syncfusion® Blazor components
145+ high-performance and responsive UI components
Dedicated support
Hassle-free licensing
TRY IT FOR FREE