To do this we first need to obtain the reference of the current row by using its index no as shown in the first line below.
By using the Grid View Row object we can find the reference of any control in the row in which user is editing the data.
These properties will automatically render Edit, Update and Cancel buttons inside Grid View column.
I am using Template Field’s Item Template and Edit Item Template for providing read only and editing interface of the same column in the Grid View.
For this situation, many developers use invisible columns (Hidden columns) in the gridview to identify that row.
Last line of the following code is calling a local method for updating the database and passing all the parameters to this method.
A datakey represents the primary key field or field of a record that can uniquely identify it in a data-bound control. Row Index represents the index of the particular row.
Many a times in our applications we use primary keys to get control of the particular record in the gridview.
The visitors to a web site can typically be divided into two groups: the users and the administrators.
In data driven web sites, users are normally allowed to view data and administrators are allowed to add, edit or delete data.
By Default, Grid View control displays Item Template which directly shows the Product Name and Unit Price columns but when user clicks Edit button Grid View automatically switches to Edit Item Template and display the control available inside Edit Item Template for user editing.