Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Howto provide form data to a BLL/DAL?

Thread Tools

Howto provide form data to a BLL/DAL?

Posts: n/a
I have written a simple DAL that returns a typed list of objects as a
source for a gridview.
I also added the necessary paging and sorting plumbing needed when
binding a gridview to an ObjectDataSource. That part is working fine.

However, the next step is to provide a search button to only populate
the grid on demand (not on pageload) and provide a few web controls
that drive the search criteria. I'm stuck on both of these tasks.

Currently, in my aspx page, the ObjectDataSource is defined as

Note: The code-behind file doesn't contain any code.

The ProductDAL looks as follows:
public class ProductDAL
private readonly static string connString =

public static List<Product> GetProducts()
return GetProducts(int.MaxValue, 0, string.Empty);

public static List<Product> GetProducts(int maximumRows, int
return GetProducts(maximumRows, startRowIndex, string.Empty);

public static List<Product> GetProducts(string SortExpression)
return GetProducts(int.MaxValue, 0, SortExpression);

public static List<Product> GetProducts(int maximumRows, int
startRowIndex, string SortExpression)
// returns a list of Product instances based on the
// data in the Northwind Products table
string sql = @"SELECT ProductID, ProductName, QuantityPerUnit,
UnitPrice, UnitsInStock FROM Products";
if (SortExpression != string.Empty)
sql += " ORDER BY " + SortExpression;

//here we're using Microsoft's DAAB objects.
SqlDataReader dr = SqlHelper.ExecuteReader(connString,
CommandType.Text, sql);
List<Product> results = new List<Product>();
int itemsRead = 0;
int currentIndex = 0;
while (dr.Read() && itemsRead < maximumRows)
if (currentIndex >= startRowIndex)
Product product = new Product();
product.ProductID = Convert.ToInt32(dr["ProductID"]);
product.ProductName = dr["ProductName"].ToString();
product.QuantityPerUnit = dr["QuantityPerUnit"].ToString();
if (dr["UnitPrice"].Equals(DBNull.Value))
product.UnitPrice = 0;
product.UnitPrice = Convert.ToDecimal(dr["UnitPrice"]);
if (dr["UnitsInStock"].Equals(DBNull.Value))
product.UnitsInStock = 0;
product.UnitsInStock = Convert.ToInt32(dr["UnitsInStock"]);
return results;

public static int TotalNumberOfProducts()
return GetProducts().Count;

Based on the above code, how do I provide the SelectedValue of say a
DropDownList to the GetProducts function so it can adjust the SQL
accordingly. Note that all of the criteria controls need to be
optional (i.e. selecting [All] in a control excludes the criteria).
Also I need to take into account that one of the criteria controls is
a multi-select ListBox which should result in an IN(a,b,c) clause in
the SQL statement.

Being very new at web development with ASP.NET, I've been puling my
hair out on how to accomplish this, so any help would be greatly

-- Hans

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Program create xsd for Crystal Report and provide all data on repo JB ASP .Net 2 04-08-2010 01:08 AM
How Much Data to Provide? Kevin Frey ASP .Net 8 12-03-2007 09:30 AM provide 2000 new computer hardware products. we provide most powerful computers on the market at reasonable prices. victoria Computer Information 0 10-11-2007 04:25 AM
Does Python provide "Struct" data structure? Daniel Mark Python 4 09-23-2006 01:39 AM
Q: Analyse data and provide a report - Arrays? Troll Perl 35 09-04-2003 05:11 PM