Gridview rowupdating keys

In this method, I am specifying the Edit Index property of the Grid View to the New Edit Index of the Grid View and then calling Bind Data() method again to bind the data.

Please note that when you will not bind the data again, Grid View will not change in edit mode.

In practical scenario you should use your existing architecture to populate and update the data.

In this article, I am going to take a simple database table that has following fields: Auto ID - Int, Auto Increment, Primary Key Page Name - Varchar(50) Page Description - Varchar(500) Active - Bit(1) In this article, I am not going to explain the workings of Sql objects but focusing on the events and methods of the Grid View that will help us in updating and deleting the records.

I will be using Sql objects directly into methods to keep the example simple and straight forward.

To populate the Grid View, I am calling Bind Data() method from Page_Load event after checking Is Post Back property of the page, so the Grid View will only be populated when there is no postback on the page (when the page loads for the first time).

This will make sure that Bind Data() method will not fire when you are going to edit, update or delete the record.

Now I have declared a Grid View Row variable named row and stored the current row being edited into it.

With the help row variable, I am going to find all the controls placed under that row in edit mode using Find Control property.