In this tutorial we are searching for our Text Box controls txt Product Name and txt Unit Price.To get the Primary Key reference we can use the Data Keys collection of the Grid View.NET Grid View markup and associated code lets first enumerate the important code pieces of this tutorial.In the above code, I set two properties Show Edit Button and Show Cancel Button of Command Field.
UPDATE: Remove the default edit button of the grid (remove the Show Edit Button="True" of Command Field) and add a link button inside another item Template.
This collection only requires the row index no and it will give us the primary key.
Last line of the following code is calling a local method for updating the database and passing all the parameters to this method.
I have following ASP controls: a textbox , a gridview, an update button, and a reset button.
When I click on the row editing button of a gridview row, then it fills the corresponding value in the textbox.Please keep in mind that there are many different ways to update the database using the Grid View control depending on the type of data you are updating and the functionality the user need and there are many solutions to achieve the same end result.