Gridview templatefield not updating

Check Box Fields are rendered with a clickable checkbox.

Since our example in the Updating Basics article used Bound Fields and a Check Box Field, the editing interface was composed of Text Box controls and an enabled Check Box control.

In this example, I am going to retrieve values from categories table of Northwind database. Drag a Grid View into the Web Form and assign Data Key Names property with the primary key column i.e. In the gdview_Row Editing and gdview_Row Deleting event, we have used the below code to retrieve categoryid from datakey of Grid View, int catid = int.

If your Page Size is 10 and you've edited the first record on the second page, Data Item Index returns 10 while Display Index returns 0, and since each page only has index values of 0-9, you get an index out of bounds error if you use the Data Item Index to find a Data Key value to use in your update code.

Fortunately, the Grid View's editing interface can be customized to include validation controls and alternative user interface elements.

It requires a little more effort, but in most cases these changes can be completed entirely through the Designer or the page's declarative markup.

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.

Search for gridview templatefield not updating:

gridview templatefield not updating-72gridview templatefield not updating-17

Leave a Reply

Your email address will not be published. Required fields are marked *

One thought on “gridview templatefield not updating”

  1. All those memories of failures which you hope could be thrown into the garbage can like a piece of paper and all those memories of successes which you hope could be saved on a c omputer like a piece of hard disk turns into endless thoughts similar to that of a math problem which the equation contains the variable infini...