.NET Discussion

.NET Issues, Problems, Code Samples, and Fixes

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?

Advertisements

August 31, 2007 - Posted by | ASP.NET, Errors, GridView, Tips & Tricks

5 Comments »

  1. well, i had the same problem
    i made an empty method & called it (DummyHandler) & i passed it to the onrowdeleting …. my code in the (RowCommand) worked!

    Comment by Mahmoud Khamees | December 6, 2007 | Reply

  2. Hey man! You saved my life, It was killing me, i changed the command as you said, it worked. thanks a million

    Comment by Prabhu | July 15, 2008 | Reply

  3. Glad I could help 🙂 Such a silly error, but I suppose it makes sense… sort of.

    Comment by Some.Net(Guy) | July 15, 2008 | Reply

  4. It works for me also, I changed commandname from “delete” to “DeleteRecord”.

    thanks

    Comment by Devidas Gaikwad | November 23, 2009 | Reply

  5. Hey, great solution and saved my days. If I search MSDN, I would never find a solution for this stupid bug.
    Thnx again. Keep doing this.

    Comment by NetPal | May 19, 2010 | Reply


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: