request help with strategy for loading multiple drop down lists

C

Chris

Hi,

Am developing a web form in asp.net using C#.

I have a drop down list box. that will contain usernames on the web page.

I have a user control in the page that contains 5 dropdown list boxes.

I'd like to create a function or procedure in the proper place that can be
called 6 times on page load event.

I believe i will pass to the procedure: 1.the connection string to database,
2. the store procedure (SQL 2000), 3. the and some other variables possibly
to determine which columns to include in the drop down list.

If I also pass the actual dropdownlist to the procedure as an object will it
become populated inside the procedure?

should this procedure simply return a dataset to be used later? or should it
also
include actually binding the data to the passed in drop down list object?

I'd appreciate analysis of this particular challenge from an object oriented
perspective.

thanks

Chris
 
T

Tasos Vogiatzoglou

1) It would be better to store connection string to web.config and read
it from there

2) I think that it would be better to create a method for each "type of
data" that you want to populate. In a similar problem, I created a
singleton DataProvider which was returning cached dataviews and a
DropDownFactory class with methods like the following

public static void PopulateLivability(DropDownList ddl)
{
ddl.DataSource = DataSetProvider.GetLivabilityDefaultView();
ddl.DataTextField = "LIT_Descr";
ddl.DataValueField = "LIT_ID";
ddl.DataBind();
ddl.Items.Insert(0,new
ListItem(Localizer.GetString("lblSelectOne"),""));
ddl.SelectedIndex=0;
}

It worked for me ...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,480
Members
44,900
Latest member
Nell636132

Latest Threads

Top