7
Developing Web Applications Using ASP.NET In this session, you will learn to: Create and retrieve database connections by using the Web.Config file Access relational data by using the SqlDataSource control and data controls Access XML data by using the XmlDataSource control and data controls Access objects as data by using the ObjectDataSource control and data controls Objectives

07 asp.net session10

Embed Size (px)

Citation preview

Page 1: 07 asp.net session10

Developing Web Applications Using ASP.NET

In this session, you will learn to:Create and retrieve database connections by using the Web.Config fileAccess relational data by using the SqlDataSource control and data controlsAccess XML data by using the XmlDataSource control and data controlsAccess objects as data by using the ObjectDataSource control and data controls

Objectives

Page 2: 07 asp.net session10

Developing Web Applications Using ASP.NET

Problem Statement:You are a developer in the Adventure Works organization, a fictitious bicycle manufacturer. You have been asked to assist in the development of the Business-to-Consumer (B2C) Web application and a related Business-to-Employee (B2E) extranet portal.Decisions on the design of the application have already been made. You have been asked to carry out a number of specific tasks in order to implement various elements of this design.

Demo: Accessing and Displaying Data

Page 3: 07 asp.net session10

Developing Web Applications Using ASP.NET

As part of the first phase of the B2C development, you have been asked to implement prototypes of pages that display and manipulate data from the AdventureWorks database.You have also been asked to implement prototypes of pages that display and manipulate data from custom object data sources and XML data from the TrailReport Web service.

Demo: Accessing and Displaying Data (Contd.)

Page 4: 07 asp.net session10

Developing Web Applications Using ASP.NET

Solution:To solve this problem, you need to perform following tasks:

1. Create and Retrieve Database Connectionsa. Add a connection string for the AdventureWorks database to the

Web.Config file.b. Programmatically retrieve the connection to the AdventureWorks

database.c. Programmatically open the connection and verify that it is open.d. Test the database connectivity.

Demo: Accessing and Displaying Data (Contd.)

Page 5: 07 asp.net session10

Developing Web Applications Using ASP.NET

2. Access Data by Using SqlDataSource Controls and Data Controlsa. Add a SqlDataSource control to the Products page.b. Set connection properties for the SqlDataSource control.c. Bind a DropDownList control to the SqlDataSource control.d. Add and configure a Subcategories GridView control with an

associated SqlDataSource control.e. Define the columns for the gvwSubcategories control.f. Add and configure a Products GridView control and associated

SqlDataSource control.g. Define columns and templates for the gvwProduct GridView control.h. Add and configure a Product Details DetailsView control and

associated SqlDataSource control.i. Add a DataList control to the ProductDetails.aspx page.j. Add an SqlDataSourceControl to the page.k. Run and test the Web application.

Demo: Accessing and Displaying Data (Contd.)

Page 6: 07 asp.net session10

Developing Web Applications Using ASP.NET

3. Access Objects as Data with ObjectDataSource Controlsa. Review the data-access code in the business object.b. Configure an ObjectDataSource control for business-data access.c. Add and configure a FormView control.d. Define the EmptyDataTemplate element for the FormView control.e. Define the ItemTemplate element for the FormView control.f. Define the InsertItemTemplate element for the FormView control.g. Add code to the Inserting event of the FormView control.h. Run and test the Web application.

Demo: Accessing and Displaying Data (Contd.)

Page 7: 07 asp.net session10

Developing Web Applications Using ASP.NET

4. Access XML Data by Using XmlDataSource Controlsa. Add an XmlDataSource object to the TrailReport.aspx page.b. Add and configure a TreeView control for the TrailReport.aspx page.c. Add code to an event procedure for the TreeView control.d. Add code for the Page_Load event of the TrailReport.aspx page.e. Test the XML data handling of the Web application.

Demo: Accessing and Displaying Data (Contd.)