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

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).
 
S

SB

Of course you can!
Step1: get your dataset
Step2: Assign the datasource property to the dataset.
You can even consider a loop to do this
for (int i=0;i<50;i++){
//assume your ddl are named ddl1,ddl2, ...
string ddlID="ddl"+i.ToString();
DropDownList ddl=(DropDownList)this.Controls[ddlID];
ddl.DataSource=myDataSet;
ddl.DataBind();
}
 
B

Bill

Thanks sb ... this helped allot.

BUT, this has caused me to rethink my approach...

Essentially, what I have here is 50 booth table row entrees (boot ID,
location, assigned company).

What I really would like here is the function of an "editable" datagrid
control (with dropdown list boxes of course) AND a "none grid" like display
(freely displayed/placed over a floor & booth diagram).

Is there anyway I can easily enjoy the best of both worlds? The efficiency
of handling datasets using a datagrid kind of control and the flexibility of
data display unrestricted to a column and row format.


SB said:
Of course you can!
Step1: get your dataset
Step2: Assign the datasource property to the dataset.
You can even consider a loop to do this
for (int i=0;i<50;i++){
//assume your ddl are named ddl1,ddl2, ...
string ddlID="ddl"+i.ToString();
DropDownList ddl=(DropDownList)this.Controls[ddlID];
ddl.DataSource=myDataSet;
ddl.DataBind();
}
Bill said:
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).
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top