In both cases, the controls are added to the controls collection for the cell.

You can see that in the case of a Template Field, the exact spacing within the control becomes significant, so it’s generally better to get a reference to the control by ID using Find Control than to use the Controls collection.

gridview rowupdating event c-89

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.

The Grid View does know the events that should be used to implement them, so the exceptions shown above are thrown when you try to perform one of these operations, but you have implemented the appropriate event handler.

The example shown here is for a Grid View, but the same types of event handlers must be implemented in roughly the same way for other data controls including the Form View, Details View, and List View. This is the final Grid View markup, so you can see the event handlers we’re going to implement.

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

The Grid View 'Grid View1' fired event Page Index Changing which wasn't handled.

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.

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).

We’re using Linq to SQL to pull data from our database and bind it to the Grid View.