Note that the RowsChanging
event can be cancelled if the delete operation is not allowed. This means that the specific row is not deleted yet. But in the event handler you call the RadGridView.Rows.RemoveAt
method passing the index of the row that you want to delete. Calling this method would delete the row triggering once again the RowsChanging
event. Have in mind two important things: unsubscribe from the event before manipulating the Rows collection in order to avoid multiple firing of the event and subscribe to it again after the Rows.RemoveAt
method call. The other thing to consider is that when you call the RemoveAt
method (deleting Row B) the index of the row that is currently being processed (Row A) in the RowsChanging
event may be changed if Row B is before Row A: for example index 0 - Row B, index 1 - Row A, index 2 - Row C. If you delete Row B, Row A's index becomes 0, not 1 as it used to be. That is why it is not recommended to manipulate the Rows collection (add/delete rows) while a delete operation is being performed.
event is fired once the delete operation is completed. Feel free to use this event for any manipulations of the collection. But feel free to use the RowsChanging
event for calculating the proper index considering whether the affected row is before or after the related rows and adjust the index +/-1.
I hope this information helps. If you need any further assistance please don't hesitate to contact me.
Dess | Tech Support Engineer, Sr.
Get quickly onboarded and successful
with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.