Gridview rowupdating no rows

29-Oct-2017 08:36 by 5 Comments

Gridview rowupdating no rows

At that point we need to get the new values so we can update the record, which is done slightly differently for the Bound Field and the Template Field.

In this example, we’ll go through a fully featured Grid View with editing, deleting, selecting, sorting, and paging functionality that is manually bound and identify the limitations and some of the workarounds. Sql Data Source, Object Data Source, Linq Data Source, etc) specified in a Data Source ID, the Grid View can automate many functions because, through the data source control, the Grid View on its own can perform the following operations: When you manually bind data to a Grid View, the Grid View itself cannot perform these operations, so they must be implemented in your code.

We’ll start with binding data to the Grid View, then build up functionality from there.

First, we’ll implement a method to databind the Grid View, which will be called whenever databinding needs to be performed.

For the Template Field, we do know the ID of the control since we specified it in the markup, so we obtain a reference to it by calling Find Control on the appropriate row of the Grid View.

The Grid View Row is the naming container for the Text Box in this case, so we need to call Find Control on the appropriate row, but we do not need to call it on the specific cell.

We’ll get to how these properties are populated shortly, but first we need to go back to the Bind Data method.

The original method shown above did not implement any sorting, but now that we have a place to store the Sort Expression and Sort Direction we need to change that.

We also need force databinding to occur when then page is loaded, which we’ll handle in Page_Load.

The required actions for paging to work are setting the new page index, setting the Data Source, and calling Data Bind (the last two through the Bind Data method).

Once we have a reference to the Text Box, we set the new last name and save the changes (through the Submit Changes method).

When a Bound Field is displaying data (not in edit mode), the appropriate text is added to the Text property of the appropriate cell.

The Grid View 'Grid View1' fired event Sorting which wasn't handled.