Normally in gridivew, All buttons are enabled (Edit, Update or Cancel)Is it possible to force the user to Click on Update/Cancel button, when in Record Edit Mode. 6 years later this information is still relevant and helps others resolve issues. There's a very good suite by Shield UI that I have a fantastic experience with and it is a very good solution for everything related to ASP.net, including grid, chart, etc..

get datakey from gridview rowupdating-73get datakey from gridview rowupdating-30get datakey from gridview rowupdating-24

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. Thanks Thank you for writing this, after searching thru an unknown number of web sites, your tutorial had my issue resolved within 10 min!

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.

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.

You need to include the Grid View Command Field column to add Edit, Update and Cancel Buttons in the Grid View. You need to include Template Field for every column you want to provide Editing because Template Field provides you both Item Template and Edit Item Template to create interface for two separate Grid View modes. You need to handle Grid View events such as Row Editing, Row Canceling Edit and Row Updating to provide desired editing functionality.

Font-Names="Verdana" Font-Size="10" Data Key Names="Product ID" Auto Generate Columns="false" onrowcancelingedit="Grid View1_Row Canceling Edit" onrowediting="Grid View1_Row Editing" onrowupdating="Grid View1_Row Updating"In the above code, I set two properties Show Edit Button and Show Cancel Button of Command Field.

Now we define a method for opening a connection with the relation database and returns a SQL connection object depending on the connection string that is passed as a parameter of the Sql Connection class constructor.

Delete a Record We can delete a record from the database table by clicking on the delete button that is in the Delete column of the Grid View.

These properties will automatically render Edit, Update and Cancel buttons inside Grid View column.