I have a gridview with AutoGenerateColumns="False".
I use TemplateField to display my Edit, Update, and Cancel buttons in the first GridView column in the corresponding ItemTemplate and EditItemTemplate fields.
Inside the ItemTemplate, I have an ImageButtong with CommandName "Edit". This works as expected, and I can set a breakpoint in the RowCommand event handler to see the name of the Event command. After it has been pressed, postback puts this line into edit mode. All text fields are displayed as they are intended.
At this point, the above EditItemTemplate is displayed with two ImageButtons inside it. He has CommandName = "Update", and the other is Cancel.
My problem is that clicking on the Update ImageButton is sent back, but the RowCommand and RowUpdating events are not triggered.
I set the required attributes in the GridView tag. (Note that in gridview EnableViewState="False"- if I set it to True, I get the standard
"Failed to load image in view. Control tree ..." etc.)
One strange thing I noticed makes me think that the ViewState problem is that if I changed the CommandName button of the Update button to “Edit”, then the postback event will be captured in the RowCommand event ...
Any suggestions are welcome. Thanks.
source
share