Rowupdating gridview not firing

21 May

For example a Sql Data Source, which is automatically added to your Web Form if you drag-n-drop your way around Visual Studio 2005.Row Updating event, doesn’t work as all samples say it should do.All samples of course assume you’re doing everything in your page, but I have to do everything in my code-behind, because on forehand I don’t know what I’ll be binding to my Grid View.This enables you to provide an event-handling method that performs a custom routine, such as canceling the update operation, whenever this event occurs.A Grid View Update Event Args object is passed to the event-handling method, which enables you to determine the index of the current row and to indicate that the update operation should be canceled.

My problem lies in that the click on the Update Image Button posts back, but neither the Row Command nor Row Updating events get triggered.

I have set the requisite attributes in the Grid View tag. I removed the master page and let the page that contained the Grid View inherit from Page, and it worked.

The problem is, I’d very much like to do so, if ASP. But I can’t set a Data Source property or anything on the Sql Data Source!!! I probably have to read the cells on the Grid View of the selected row, find the controls, get the values from those and insert those into my Data Set.

Which means I won’t make my 70% code reduction Microsoft has always promised me.

Within the Item Template I have an Image Buttong with a Command Name of "Edit".

This works as expected and I can put a breakpoint in the Row Command event handler to see the "Event" command name.

(Note, in the gridview the Enable View State="False" - if I set it to True I get the standard "Failed to load viewstate. error) One strange thing that I've noticed that makes me think it's a View State problem is that if I change the Command Name of the Update button to "Edit" that postback event does get captured in the Row Command event... Something in my inheritance stack (or something in the MS controls) didn't work the way I had it set up.

For a while now I’m trying to figure out why my method, triggered by the Grid View.