Solved

Three Tier Design for DropDownList with parameterized stored procedure

Posted on 2010-11-16
3
670 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

628 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