Gridview1 rowupdating e newvalues
The way we’ll accomplish this is to create two properties that store those values in View State.We’ll get to how these properties are populated shortly, but first we need to go back to the Bind Data 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.When the Bound Field is in Edit mode, things are a little different.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.After specifying the query, we add the appropriate sorting. When you bind a Grid View through a Data Source ID, the Grid View will update this value since it is internally tracking the sort expression, so it knows when to switch between ascending and descending.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.
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.First, we’ll implement a method to databind the Grid View, which will be called whenever databinding needs to be performed.We’re using Linq to SQL to pull data from our database and bind it to the Grid View.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.