So we need to create a Stored Procedure on which we pass all parameters that are updateable along with the primary key value, in other words the row data's key value that is being updated.We use the Row Updating event of Grid View to update the record in the database table.We first of all create a Stored Procedure that gets the Id of an employee as a parameter from the Grid View on whichever row the user clicked. In this event, first we get the datakey value that is the id of an employee of whichever row the user clicked and that id is passed as a parameter to the Stored Procedure. According to the above, in these three operations we use three events of the Grid View for each operation.Point numbers 2 and 3 are performed after point 1 is performed.1.There are many articles and tutorials around that illustrate the use of Grid View control along with the new Data Source Controls.When attached with a Data Source control Grid View performs tasks such as paging, sorting and editing automatically i.e. However, at times you require to bind the Grid View with a Data View or Data Table directly.
This calls for some extra coding from developer's end. As an example we are going to use Employees table of the Northwind database. Add three Bound Fields and a Command Field to the Grid View with the help of Fields dialog (see below).Here we can update Name, Emp_Code and Emp_Age fields depending on the Id field of the "EMPLOYEE" table.