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.Despite the plethora of provided features, there will often be situations in which additional, non-supported features will need to be added.
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.
In the above tutorial I tried to give you one of the easiest solutions and I hope you can go explore Grid View control editing further after learning the basics from this tutorial.
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.
Now I will show you the C# code behind file of the above ASP.
While the Select button works in many situations, it may not work as well for others.
Rather than using a button, two other user interface elements are commonly used for selection: the radio button and checkbox.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.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.NET page that will handle different Grid View events to provide complete editing functionality.