Detailsview itemupdating cancel update


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.

detailsview itemupdating cancel update-41

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.

If we were using a Template Field instead, the compiler translates the markup in the templates to the appropriate types of controls in the same way as the page markup in parsed.

For this example, the Item Template would be transformed into a Literal control, and the Edit Item Template would be transformed into a Literal control, a Text Box, and a Literal control (the literal controls would include the spacing between the Edit Item Template tags and the Text Box tags).

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.