Start Inserting updating and deleting data with the objectdatasource

Inserting updating and deleting data with the objectdatasource

The download at the end of this article includes another Details View example that illusrated adding validation controls and customizing the inserting interface to prompt the user for the new product's category via a drop-down list of available category choices.

These controls allow page developers to declaratively access and modify data without writing any code to perform the data access. These controls allow for a declarative approach to working with data, without needing to write any cumbersome data access code.

This article is one in a series of articles on ASP. The articles we have explored in the series thus far have focused on understanding the core concepts of the data source controls and how to retrieve data from the database.

In addition to retrieving data, the data source controls can also insert, update, and delete data.

Likewise, if the user puts in an invalid unit price value (like "expensive!

"), an error will occur when attempting to insert the illegal value into the database.

We could create a simple Web Form that included Text Boxes, a Drop Down List, and a Check Box control to collect these input fields, along with an "Add Product" Button control that, when clicked, would insert the new product into the database.

In addition to these user input controls we could also add a Sql Data Source control to handle the actual insertion.

This example illustrates only the simplest facilities of the Details View and omits important steps in a real-world application, such as input validation and customizing the inserting interface.

Dzisiaj jest:
23-Apr-2019 21:45