ASP.NET GridView: ‘The Gridview [x] Fired Event RowDeleting Which Wasn’t Handled’
Came across this error today which left me scratching my head for a bit. Basically, I have a Gridview with a Select column, two Button columns, and a few Bound columns. I gave each button column a unique CommandName property, and one of them was “Delete”, because I was using it to delete the row (I was doing it manually). I am handling the buttons’ click events in the RowCommand event and discerning which is which by
e.CommandName. However, every time I clicked the delete button, I would get the error:
The Gridview [x] Fired Event RowDeleting Which Wasn’t Handled
This struck me as odd, because I wasn’t doing anything with a “RowDeleting” event. I tried putting some random code in there, nothing worked, although the code was getting executed every time. After trying any and everything I could think of, I decided to change the CommandName “Delete” to “Delort” (courtesy of Strongbad 🙂 ) and viola! It worked!
Apparently, the CommandName “Delete” is reserved for the Built-In Editing Functionality of the GridView. I’m sure there are others reserved, too, but I didn’t really look into it any further. Who knew?