Here we can update Name, Emp_Code and Emp_Age fields depending on the Id field of the "EMPLOYEE" table.
Create SQL Connection We need a connection with a Microsoft SQL Server database so we can access data and perform an operation on it.
We define a connection in the web.config file and give a name to the connection string.
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.
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.
We get the Id value using the row index and another Text Box value is also retrieved.
All updated values are passed to the Stored Procedure.Fortunately Grid View can also be used without attaching with the Data Source Controls. In this article we will see how paging, sorting and editing can be implemented in a Grid View control that is bound 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).The Edit Index property of a Grid View determines the index of a row in edit mode. Update record and get updated state of the Grid View.When a Grid View row is in edit mode then we can update the row's record in the relational database table.The Grid View control is a tabular databound control but sometimes it is used like a spreadsheet control. NET 2.0 and is an improved version of the Data Grid control. We can use this to display data from a database and edit, sort and select the data.