Gridview Editing without Autogenerated Buttons
Posted on 2008-10-24
I really hope I am overlooking something obvious here.
Summary: How do I use a fixed command button (ie not autogenerated) to fire off the built-in editing capabilities of the gridview?
Long-winded details/background: I have (had) a working gridview that did all the editing just as it was supposed to. However, I discovered that when the user scrolled down to click the autogenerated Edit link for a row "way down the list", the postback would cause the grid to reset to the top. This would force the user to have to scroll all the way down to the row that was now (properly) open for editing.
--- End of long-winded details. :)
So having made the change, I am now getting an error in the RowCommand event where it tries to determine the row index.
"Dim index As Integer = Convert.ToInt32(e.CommandArgument)" ==> Input string was not in a correct format
This line works flawlessly for the other command buttons (I have a couple other buttons on the row) and even worked before for the Edit until I made the change.
What am I missing? At this point, the only thing I have changed has been to add the item/edit template for the buttons, with the commandnames set accordingly ("Edit", "Update", "Cancel") and to set "AutogenerateEditButton" to false.