Last Updated: 20 Jul 2022 11:08 by ADMIN
Created on: 20 Jul 2022 08:31
Category: UI for WinForms
Type: Bug Report
DataError does not cancel

Repro steps:

  1. Make a datatable with a string-column with a max. length of 10 characters.
  2. Add a row with a string of max. 10 characters.
  3. Bind it to a RadGridView
  4. Add an event-handler to DataError which will cancel the action if a data error occurs.
  5. In the UI, enter data into the cell. Make it longer than 10 characters.

Expected behavior:

  1. The same behavior as CellValidating.
  2. De user stays inside the editor so it can modify the text.

Observed behavior:

  1. The editor is closed, the new text is not displayed.
Dess | Tech Support Engineer, Principal
Posted on: 20 Jul 2022 11:08

Hi, Martin,

If you try to set a value to a cell in RadGridView that violates the settings in the DataTable, you are expected to observe the following error:

 this.radGridView1.Rows[0].Cells["Title"].Value = "This is a very long string";

The DataError event will play an important role in this situation which allows you to handle this case. This event offers GridViewDataErrorEventArgs which is a derivative of CancelEventArgs from where the Cancel argument is inherited. However, the Cancel argument is not used in this case. It is just enough to subscribe to the DataError event and the above error message wouldn't be shown to the end user. If you decide to notify the user for the incorrect data, you can show a message:

        private void radGridView1_DataError(object sender, GridViewDataErrorEventArgs e)

I believe that it would be helpful for achieving your goal.

Dess | Tech Support Engineer, Principal
Progress Telerik

The Premier Dev Conference is back! 

Coming to you live from Progress360 in-person or on your own time, DevReach for all. Register Today.

Posted on: 20 Jul 2022 10:46
Let me rephrase: What does the GridViewDataErrorEventArgs.Cancel do?
Dess | Tech Support Engineer, Principal
Posted on: 20 Jul 2022 10:37
Hello, Martin,  

RadGridView provides a convenient way to perform validation before data is committed to the underlying data source. You can validate data by handling the CellValidating event which is raised by RadGridView when the current cell changes or when the cell loses input focus (when pressing Enter key). Canceling The CellValidating event prevents the user from exiting the cell until a valid editor value is entered or the edit process is canceled. 

The DataError event is not designed to work in a similar way like the CellValidating event. The DataError fires when an error on the DataSource side occurs, e.g. ConstraintException. It is not expected to keep the editor opened while a valid value is entered. 

I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

Dess | Tech Support Engineer, Principal
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at