the Deleted event fires after a delete is performed). There's nothing wrong with that, but I'd recommend using the similarly named event on the Data View that the Data Source is bound to.
The simplest solutions for this error is : Just change the “Command Name” property of the “Edit” button from “Edit” to “Edit Row”(or something else which is relevent to you but make sure it is not “Edit”). After scratching my head for sometime I found that the words like “Edit” are reserved to invoke some built in functionality of the Grid View.
When I Filter the data using dropdown selected Index Changed event the gridview shall load data based on what is searched.
I need to do the updating operation on what row is clicked.
Storing datatable in View State is not a good practice as it increases the size of your page and reduces the performance, also View State can be deciphered on the client side, so the Data Table is not secure.
I removed everything I did with View State and edited the original post again with what I currently got. I cannot sort the Grid View because I'm trying to sort with Your code doesn't have Data Source ID.
In many ways, the parameters passed to the Sql Data Source's events give you more control than any of the other Data Sources. Using the Data View event also means that you're not tied to any particular Data Source.
For instance, in the SQLData Source, the e parameter gives you access to the Command object being used and all of its properties. Select Command Type = Sql Data Source Command Type. If you decide to switch from SQL to Entity Framework, for instance, you won't have to change any code if you've used the Data View's events.
I am using a Template Field to display my Edit, Update and Cancel 'buttons' in the first column of the Grid View within respective Item Template and Edit Item Template fields.
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.