Solved

Three Tier Design for DropDownList with parameterized stored procedure

Posted on 2010-11-16
3
665 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Before You Read The Article Please make sure you understand these two concepts: Variable Scope (http://www.php.net/manual/en/language.variables.scope.php) and Property Visibility (http://www.php.net/manual/en/language.oop5.visibility.php).  And to …
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…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

762 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

23 Experts available now in Live!

Get 1:1 Help Now