Now I will fetch the records from this table and display them in Gridview data control and edit, update and delete the record.

If you found this article useful, please share and follow on Facebook, Twitter, Google Plus and other social media websites. Please put your thoughts and feedback in comments section.

Oddly I have no idea why the data item would not be available given that this particular grid is bound to a Data Table which has persistent backing and is live on the form.

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.

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.

Also notice that if you have both Button Fields/Command Fields and template items that have command arguments, the Command Argument will contain different things.

In the case of a Command Field the Command Argument is the Row Index.

From there I can then retrieve the Data Row based on the index.

Again it seems odd given that we are firing a ROW level Row Command event that there's not an easier way to get row level context even when we are using a Command argument.

First here's the implementation of a couple of Link Buttons in the template I can specify a command argument which is nice because it lets me be very concise about what data I want to pass to the Row Command event.

In the event handler the code to retrieve the PK in this case becomes considerably simpler, but as we'll see it's a little harder to get a reference to the underlying data source control if that needs to be updated.

At that point I have the data I need to be on my way and do my business logic (which in this case is very simple).