Rowupdating event in gridview
In this article, I will show you how to use an ASP.NET 2.0 Grid View control to view, add, update, and delete data in a SQL database. In this code below code, you see database table columns binding with the bound fields and formatting is provided using the template fields.I hope the above information was a little bit helpful for you, kindly let me know your valuable feedback or thoughts.The visitors to a web site can typically be divided into two groups: the users and the administrators.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.
This collection only requires the row index no and it will give us the primary key.
If user clicks the Cancel button while Grid View is in editing mode, you need to Cancel the Editing process and also need to reset the Edit Index property to -1 in the Row Canceling Edit event of the Grid View control as shown below: The last step is to handle the Row Updating event to actually update the back end database.