Rowupdating cell value
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.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.Bind Data could be called in Page Index Changing, but to show that it the event is raised, we’ve handled that in Page Index Changed.When the Bound Field is in Edit mode, things are a little different.In that case a Text Box is created and added to the Controls collection for the appropriate cell (and it's the only item added to the Controls collection, so it's Controls).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.
The way we’ll accomplish this is to create two properties that store those values in View State.
We’re using Linq to SQL to pull data from our database and bind it to the Grid View.
We’ll revisit this method when we implement the sorting functionality.
Save all or press "Ctrl S" and hit "F5" to run the page, the page will look as in the following image: Click on "Edit the Grid View", it will display Textboxes in each cell as in the following image: Edit the value(s) here and click on the Update link, it will update all the data or to remove it click on the "Delete" link above the image shown.
One note will be helpful for you, while describing Columns in Grid View if you are using a boundfield then create objects of the control using cells[index] in the rowupdateing event of Grid View, but if you are using controls itself like Label or textboxes etc then use Fincontrol("stringid").