aspdotnet-suresh offers C#articles and tutorials,csharp dot net,articles and tutorials, VB.

row editing and updating in gridview in asp net-26

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.

In this article we create a Gridview from database and add some additional operations such a add, edit and delete data in the Grid View control.

In the Page_Load event, you simply load your data from the database and bind it with the Grid View control as shown below: For brevity I am not storing connection string in the web.config and also not using any Data Access Component.

Next event is the Grid View Row Editing event to give ASP. You need to set the Edit Index property of the Grid View with the New Edit Index property of the Grid View Edit Event Args class.

In the above code, I set two properties Show Edit Button and Show Cancel Button of Command Field.

These properties will automatically render Edit, Update and Cancel buttons inside Grid View column. NET View_Insert_Edit_Update_If using Sql Data Source about Data Access then you can refer here Hope that helps!The visitors to a web site can typically be divided into two groups: the users and the administrators.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.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.To get the Primary Key reference we can use the Data Keys collection of the Grid View.