Solved

Three Tier Design for DropDownList with parameterized stored procedure

Posted on 2010-11-16
3
666 Views
Last Modified: 2012-05-10
Good morning,

Currently I've been populating DropDownList in the code behind of web page. Opening the connection, using the command object to run the stored proc, and binding it to the DropDownList with a procedure and calling it in the page load event.

I could end up having 24 or more of these through out the site. So I think it's time for me to try using a Data Access Layer and Business Logic Layer.

What would be the best approach for the following code? It populates three DropDownList using the same stored procedure but with different parameter values.

I haven't found any examples out there as of yet.

Thanks MyCode.pdf
0
Comment
Question by:tis9700
  • 2
3 Comments
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 500 total points
ID: 34150491
I think you can have one method to which you supply the name or type of list to populate. The other option is to have a method for each of the lists in the business logic layer which then uses the single stored procedure to populate the list.
0
 

Author Comment

by:tis9700
ID: 34154481
IHi Code Cruiser,

I'm not clear on what you're suggesting. Could you explain a little more.

Are you refering to List(Of Type)? And using it to store a list of my parameter values? I think I need to see a tutorial on this, do you know where I can find one?
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 34154827
No. By list, I meant dropdownlist. You can have a single method which accepts the name or type of list to populate. Here is an example

Public Function GetList(ListName As String) As DataTable
    If ListName = "City" Then
       ...
    ElseIf ListName = ...
    ...
    End If
End Function

CityList.Datasource = GetList("City")

Another option is to use an enum

Public Enum ListTypes
City
ContactType
...
End Enum

Public Function GetList(ListType as ListTypes) As DataTable
      If ListType = ListTypes.City Then
      ...
      End If
End Function

CityList.Datasource = GetList(ListTypes.City)


The third option is to have a separate function for each list so

Public Function GetCityList() As DataTable
End Function



Note: Where ever I used "...", it means that other code can go in there.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Dependencies in Software Design In software development, the idea of dependencies (http://en.wikipedia.org/wiki/Coupling_%28computer_programming%29) is an issue of some importance. This article seeks to explain what dependencies are and where they …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now