Updating database table datagridview
To accomplish this we need to specify values for the Sql Data Source control s statement created in Step 2.
For now, let s use the Properties window in the Designer, although the Configure Data Source wizard or declarative syntax option would work just as well.
To illustrate this, let s take an example from the table and a Grid View that renders this data.
Our goal is to extend this example to allow for the user to delete products via the Grid View.
Refer to the Adding Validation Controls to the Editing and Inserting Interfaces and Customizing the Data Modification Interface tutorials for more information. Then, after completing the wizard, choose to configure the Select Query from the Properties window (or, alternatively, go back to the Configure Data Source wizard, but use the Specify a custom SQL statement or stored procedure option). If such customizations are required, you need to make them manually, either through the Properties window, the Specify a custom SQL statement or stored procedure option in the wizard, or via the declarative syntax.
The Sql Data Source control supports the same operations, but the approach is different, and this tutorial shows how to configure the Sql Data Source to insert, update, and delete data.
As Figure 4 shows, when the page is visited through a browser a Delete button is included. Figure 4: Each Grid View Row Now Includes a Delete Button (Click to view full-size image) Upon clicking a Delete button, a postback occurs, the Grid View assigns the Figure 5 depicts this interaction graphically.
Refer back to the Examining the Events Associated with Inserting, Updating, and Deleting tutorial for a more detailed discussion on the chain of events associated with inserting, updating, and deleting from a data Web control.
For now, leave this checkbox unchecked; we'll examine optimistic concurrency with the Sql Data Source control in the next tutorial.
After checking the Generate statements checkbox, click OK to return to the Configure Select Statement screen, then click Next, and then Finish, to complete the Configure Data Source wizard.