Please join our friendly community by clicking the button below - it only takes a few seconds and is totally free.
You'll be able to ask questions about coding or chat with the community and help others.
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.
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.
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.
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.
I want to provide my user a Gridview filled with data from database, allowing him to edit these records not in order to update the database, but in order to insert edited rows in db as new records through a stored procedure. - to use Edit built-in capabilities (Edit button, Edit Item Template etc.) because I don't need to make any real updating and I don't have a clear idea of how to "bypass" the parts I don't want.) Cri Thanks, yousuf... I think Edit Index is nothing, because the whole Edit thing is never raised.