We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Preventing DataGrid writing to the DataSource on validation failure

I'm experiencing an issue with the datagrid that I'm not sure should be the expected behavior:

  1. Have a datagrid bound to a list of object 'MyObject'
  2. Have a property on MyObject 'MyProperty'
  3. Assign a validation attribute to MyProperty: [Required(ErrorMessage = "TEST: Required")]
  4. Run the website. Edit the MyProperty column value and set it to "" (blank).
  5. It displays the validation error correctly BUT it still writes the blank value to the MyObject.MyProperty object.

- Why is it writing back values that fail validation? I would expect the grid UI to display the invalid value, but not have it written to the object.

- Is there any way to tell the datagrid 'Don't write back values if the validation fails"


1 Reply

SP Sarveswaran Palani Syncfusion Team April 6, 2023 03:53 AM UTC

Hi Jonathan,

Greetings from Syncfusion support.

From your query, we suspect that your facing issue in writing back values when validation fails. By default, the component doesn't perform a save operation if validation fails during adding/editing values. We prepared sample based on your requirement using Data annotation and custom validation. We have attached sample for your reference. We kindly request you to provide a video demo of an issue and simple issue reproducible sample or reproduce the reported issue in the provided sample. It’ll be helpful for us to further validate your query and provide solution ASAP from our end.


Attachment: SfGridValidation_d0a8d682.zip

Live Chat Icon For mobile
Up arrow icon