Please refer to the attached sample project and run it. Select a random item and press the button. You will obtain the error. If no selection is available, the item is removed as expected.
Workaround: use Begin/EndUpdate block while deleting a record from the DataTable: