skip to content »

arisufit.ru

Updating row in gridview

The idea is to give the user an Excel like interface where they can edit the rows with custom data and finally click the update button to persist the data in the database.Matt’s solution was great but lacks a very important detail.

updating row in gridview-10updating row in gridview-51updating row in gridview-4updating row in gridview-36

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.In data driven web sites, users are normally allowed to view data and administrators are allowed to add, edit or delete data.In this tutorial I will show you how you can create an editable Grid View control for administrators to modify database records directly into the Grid View control. NET Grid View control provides an easy way to edit and update data with the help of Command Field column type.The default Command Field arrangement is such that the Edit, Update and Cancel buttons are displayed in a column as shown below: The problem with this design is that the Grid View edit column always occupies some screen real estate.For this situation, many developers use invisible columns (Hidden columns) in the gridview to identify that row.

We can achieve the same functionality using Datakeys.

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.

In this article, I am going to explain how to manipulate data using Grid View control.

This article scope is limited to Updating and Deleting records using Grid View and I am not using any readymade Data controls for that but manually writing all event methods.

Now I will show you the C# code behind file of the above ASP.