Return to the "ASP.net 2.0 Data Tutorial directory"
Introduction
To end the previous sections, we've explored how to display data using the GridView, DetailsView, and FormView controls. These controls simply manipulate the data that is provided to it. Generally, these controls access data by using a data source control, such as ObjectDataSource. We've seen how ObjectDataSource plays an agent role between the ASP.net page and the potential data. When a GridView needs to display data, it calls the ObjectDataSource Select () method, which instead calls a method from our business Logic layer (BLL), and then calls a The appropriate data access layer (DAL) table Adapter (TableAdapter) method, which sends a select query to the Northwind database.
Remember in our tutorial when you create a table adapter in the DAL, Visual Studio automatically adds methods for inserting, updating, and deleting data from a potential database. In addition, in the section creating a business logic layer, we have designed the BLL method of the Dal method that invokes these data changes.
In addition to its select () method, ObjectDataSource also has the insert (), Update (), and Delete () methods. Like the Select () method, these three methods map to an implied object. When you configure inserts, updates, or deletes data, the GridView, DetailsView, and FormView controls provide a user interface to modify the potential data. This user interface invokes the ObjectDataSource Insert (), Update (), and Delete () methods, which then invoke the associated method of the implied object (see Figure 1).
Figure 1:objectdatasource Insert (), Update (), and Delete () methods provide a proxy to BLL
In this section we'll look at how to map the ObjectDataSource Insert (), Update () and Delete () methods to classes in BLL, and also see how to configure the GridView, DetailsView and FormView controls provide the ability to modify data.
First step: Create the Insert, update, and delete tutorial pages
Before we begin to explore how to insert, modify, and delete data, let's take some time to add the asp.net pages that are needed in this section and in the next section in our site project. First, add a new folder named EditInsertDelete. Then, add the following asp.net pages to this folder and verify that each page is associated with the Site.master master page:
· Default.aspx
· Basics.aspx
· DataModificationEvents.aspx
· Errorhandling.aspx
· UIValidation.aspx
· Customizedui.aspx
· Optimisticconcurrency.aspx
· Confirmationondelete.aspx
· Userlevelaccess.aspx
Figure 2: Adding the pages of these tutorials associated with data changes