I have a Telerik RadGridView where users can add rows and edit inline. I am using the RowValidating event to ensure that users don't leave a row without filling in the necessary fields.
However, the RowValidating event has started to get called when adding a new row which means that the new row is showing in red as soon as it is created as the user hasn't filled in the necessary fields yet. How can I prevent the RowValidating event from being called (or know to ignore it) when a new row is being added?
NOTE: I can't just check whether there is no data and return at the start of the method if so, as I want to handle that scenario differently to allow users to delete empty rows.
You can check the EditOperationType of the GridViewRowValidatingEventArgs.
Add the following line to the beginning of the RowValidating method:
if (e.EditOperationType == GridViewEditOperationType.None) return;
This will skip the rest of the method if it is adding a new row.
NOTE: I don't know why the EditOperationType is 'None' when adding a new row rather than 'Insert', but that is what it seems to be.