Title: Bookstore Application: Middle Tier
131
- Bookstore Application Middle Tier
- Introducing Code-Behind Files and Databound Web
controls
2Outline
- 31.1 Reviewing the Bookstore Application
- 31.2 Programming the Books Pages Code-Behind
File and Creating a Databound ListBox - 31.3 Coding the BookInformation Pages
Code-Behind File and Creating a Databound
DetailsView - 31.4 Internet and Web Resources
- 31.5 Wrap-Up
3Objectives
- In this tutorial you will learn
- Write the functionality for the middle tier,
using Visual Basic code. - Modify code-behind files in a Web application.
- Use databound Web controls.
4Action/Control/Event (ACE) Table for
theWeb-Based Bookstore Application
Figure 31.1 ACE table for the Web-based
Bookstore application. (Part 1 of 2.)
5Action/Control/Event (ACE) Table for
theWeb-Based Bookstore Application (Cont.)
Figure 31.1 ACE table for the Web-based
Bookstore application. (Part 2 of 2.)
6Changing the Class Name in Books.aspx.vb
Figure 31.2 Code-behind files for the
Books.aspx and BookInformation.aspx pages in the
Solution Explorer.
7Changing the Class Name in Books.aspx.vb (Cont.)
Figure 31.3 Code-behind file for the Books.aspx.
8Changing the Class Name in Books.aspx.vb (Cont.)
Figure 31.4 Changing the applications class
name.
9Changing the Class Name in Books.aspx.vb (Cont.)
Figure 31.5 Changing the Books.aspx Inherits
statement.
10Defining the Click Event Handlerfor the
Books.aspx Page
Figure 31.6 informationButton_Click event
handler definition.
11Creating a Databound ListBox usingan
ObjectDataSource
Figure 31.7 Creating a databound ListBox in the
GUI.
12Creating a Databound ListBox usingan
ObjectDataSource (Cont.)
Figure 31.8 Creating a new data source.
13Creating a Databound ListBox usingan
ObjectDataSource (Cont.)
Figure 31.9 Choosing a data source type.
14Creating a Databound ListBox usingan
ObjectDataSource (Cont.)
Figure 31.10 Choosing a business object.
15Creating a Databound ListBox usingan
ObjectDataSource (Cont.)
Figure 31.11 Defining data methods.
16Creating a Databound ListBox usingan
ObjectDataSource (Cont.)
Figure 31.12 Finish defining Data Source for
ListBox.
17Defining the Page_Load Event Handler forthe
BookInformation.aspx Page
Figure 31.13 BookInformation class.
18Defining the Page_Load Event Handler for the
BookInformation.aspx Page (Cont.)
Figure 31.14 BookInformation class.
19Defining the Page_Load Event Handler for the
BookInformation.aspx Page (Cont.)
Figure 31.15 Page_Load event handler modified
to set a parameter value and open a database
connection.
20Defining the bookListButton_Click EventHandler
for the BookInformation Page
Figure 31.16 Definition of the
bookListButton_Click event handler.
21Creating a Databound DetailsView Usingan
ObjectDataSource
Figure 31.17 Select ltNew Data Sourcegt in the
Choose Data Source TextBox.
22Creating a Databound DetailsView Usingan
ObjectDataSource (Cont.)
Figure 31.18 Defining the data methods.
23Creating a Databound DetailsView Usingan
ObjectDataSource (Cont.)
Figure 31.19 Defining the querys parameters.
24Creating a Databound DetailsView Usingan
ObjectDataSource (Cont.)
Figure 31.20 Modifying the displayed fields in
the DetailsView.
25Creating a Databound DetailsView Usingan
ObjectDataSource (Cont.)
Figure 31.21 Removing displayed fields from the
DetailsView.
26Creating a Databound DetailsView Usingan
ObjectDataSource (Cont.)
Figure 31.22 Final Fields dialog.
27Outline
Creating a Session item
Redirecting client browsers to BookInformation.asp
x page
28Outline
(1 of 2 )
Create a ProductsTableAdapter object so that we
can call its methods to get the data
Get the data from the database
29Outline
(2 of 2 )
Using a Session item to determine the row number
of the selected book.