Asp net gridview rowupdating e oldvalues

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

asp net gridview rowupdating e oldvalues-36asp net gridview rowupdating e oldvalues-32

It is only the answer if you never change the header text in the gridview.

The asker of the question wanted to get the database field name by index.

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

The Grid View 'Grid View1' fired event Row Deleting which wasn't handled. When I say manually databinding I mean not using a data source control specified as a Data Source ID, but rather setting the Grid View’s Data Source equal to the appropriate data object and calling Data Bind. NET 2.0 are familiar with how to deal with this, but since ASP.

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.

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.

For the Bound Field, we don’t know the ID of the Text Box since it’s autogenerated by the Bound Field, so we obtain a reference to it by getting the first control in the appropriate cell in the edited row.

Since it’s a Bound Field, the Text Box is going to be Control[0].

Once we have a reference to the Text Box, we set the new first name.

In addition to that, we’re resetting the Edit Index and Selected Index when the page is changed to avoid cases, for example, where you change pages and are suddenly editing a different item.

Tags: , ,