Main ASP .NET Tutorial Index 

Tutorial 2: Creating a Business Logic Layer

 

Scott Mitchell

June 2006

Download the ASPNET_Data_Tutorial_2_CS.exe sample code.

Contents of Tutorial 2 (Visual C#)

Introduction
Step 1: Creating the BLL Classes
Step 2: Accessing the Typed DataSets Through the BLL Classes
Step 3: Adding Field-Level Validation to the DataRow Classes
Step 4: Adding Custom Business Rules to the BLL's Classes
Summary

 

Step 2: Accessing the Typed DataSets Through the BLL Classes

In the first tutorial we saw examples of working directly with the Typed DataSet programmatically, but with the addition of our BLL classes, the presentation tier should work against the BLL instead. In the AllProducts.aspx example from the first tutorial, the ProductsTableAdapter was used to bind the list of products to a GridView, as shown in the following code:

ProductsTableAdapter productsAdapter = new ProductsTableAdapter();
GridView1.DataSource = productsAdapter.GetProducts();
GridView1.DataBind();

To use the new BLL classes, all that needs to be changed is the first line of code – simply replace the ProductsTableAdapter object with a ProductBLL object:

ProductsBLL productLogic = new ProductsBLL();
GridView1.DataSource = productLogic.GetProducts();
GridView1.DataBind();

The BLL classes can also be accessed declaratively (as can the Typed DataSet) by using the ObjectDataSource. We'll be discussing the ObjectDataSource in greater detail in the following tutorials.

Figure 3. The List of Products Is Displayed in a GridView

 

 

 

 

Go to top of page or next part of tutorial

 
eXTReMe Tracker