asp.net 2.0 Data Tutorial 16: Overview Inserting, updating, and deleting data

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.