skip to content »

457040.ru

Difference between rowediting rowupdating

difference between rowediting rowupdating-30

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.

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).The important point is not which of these two events call Bind Data, but one of them must or the Grid View will not be updated. When bound using a Data Source ID, the Grid View internally tracks the current Sort Expression and Sort Direction, and those are available through properties with the same names.When you manually bind the Grid View, this tracking does not occur, so we must implement some mechanism for tracking those values.We also want it to be something persistent, so that, for example, if you sort, then page, the sort is maintained.The way we’ll accomplish this is to create two properties that store those values in View State.We’re sorting on the appropriate field based on the Sort Expression, and setting the direction based on Sort Direction by calling either the Order By or Order By Descending methods. As with paging, we also reset the Edit Index and Selected Index when sorting.

Finally we need to populate the Sort Expression and Sort Direction when they change, and we’ll handle that in the Sorting event. Also like paging, so show that it does get called, databinding is handled in the Sorted Event ( First, we obtain the User ID of the affected row from the Grid View Data Keys collection, which we use to pull the appropriate record from the database.

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.

NET forums is how to deal with exceptions like The Grid View 'Grid View1' fired event Row Editing which wasn't handled.