HOW TO: Create a single DataSet bound object used by 50 DropDownList box controls in the same web

B

Bill

I have a seating chart web form that has over 50 entry field controls
(tables/booths) where I use a DropDownList box to select a single company
name from a single large list of organizations (200 plus conference
attendees). All web form datavalues will be one of the same 200
organizations in this list. I would like to avoid creating 50 separate exact
copies of the same DataSet object. Can you help?

Q. Exactly how do I use the same DataSet object in all 50 DropDownList boxes
on my web form with out creating it 49 more times? Isn't there a simple
way of "referring to" or "cloning" or binding each of the 50 web controls to
the same (single dataset created by a single db query).
 
G

Guest

If I am understanding your question right, you can in the same function fill the dataset and use it as the datasource for all the dropdownlists and then bind them each separately - call this function once from your page load.
 
C

Cowboy \(Gregory A. Beamer\)

You can bind the same dataset (or rather DataViews of DataTables) to
multiple controls. If you want to further filter, you can use a DataView
with a filter condition set.

DropDownList1.DataSource = ds;
DropDownList2.DataSource = ds;

You do have to individually bind each time. However, you can create the drop
down as a user, or better yet, server control and use the same drop down
numerous times. If you cache the information, it will only take one trip to
the database to fill all of the instances of the control.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

**********************************************************************
Think Outside the Box!
**********************************************************************
 
B

Bill

Thanks a bunch....I knew it had to be something simple like
that...Now...something even more basic

Can someone give an c# example of how I might loop through each of "booth"
form id's (1....50) to attach this single datasource and bind it to that
specific web form control?
----------------------------------------------------------------------
// My Attempt at Coding this follows.

// For booth IDs Index = 1 through 50 (increment by 1 until Index > 50)

for (i=1; i<51; i++) {

// How do I use BIndex to create a string value for each control name

boothIDstr = "Booth" + Convert.ToString(BIndex);

// How do I use the resulting boothIDstr to assign/bind the single

DataSet(ds) to a control of that name.

??? (boothIDstr).DataSource = ds;
??? (boothIDstr).Bind();
}
// End loop

Will something like this work?
 

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,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top