The code first has to retrieve the Grid View Row, which is done by retrieving the Command Argument which in this case a row index of the rendered grid view items.
In my code I tend to write the databinding logic as part of the page logic which usually is just a couple of lines of code.
Anyway, the problem isn't that it can't be done 'manually' - but rather that there are a myriad of ways that you can hook up custom link/command processing and they are all similar but yet quite different.
The typical scenario might be a list where you can toggle certain options or where you can fire an operation that otherwise updates the data that's underlying the grid.
I tend to use business objects in my applications so using the standard data controls doesn't work very well, nor would it really buy much in terms of abstraction.
None of them feels natural to me, so quite frequently - especially if I haven't written that code in a while - I spent way more time than I should rediscovering what approach I should use the hard way.
So I'm taking a few minutes - for my own sake - to write this stuff down so I can look it up next time I have a brain fart Using a Button Field you can specify a Command Name which in turn provides the On Row Command event some context as to what type of operation you are dealing with in Code Behind.
In Code Behind you have to do a bit of work though if you want to retrieve the proper context from a Data Item.
This article explains how to perform insert, update and delete operations in ASP. Let us take an example to perform CRUD operations using Entity Framework Database First approach.
Suppose we’ve to work on Customer table having Category ID as foreign key.