By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,081 Members | 1,342 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,081 IT Pros & Developers. It's quick & easy.

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

P: n/a
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).
Nov 15 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
If all of the controls are on the same form, and assuming they have a
similar name that's different from other drop down lists on the form
(assuming their are others), you can iterate through all the controls on the
form, and for all combo boxes that match your name criteria, you could bind
the dataset to them. Something like:

DataSet ds = GetMyDataSet();

foreach(Control ctrl in this.Controls)
{
if (ctrl.GetType() == typeof(DropDownList) && ctrl.Name.Substring(1, 4) ==
"seat")
{
((DropDownList) ctrl).DataSource = ds;
((DropDownList) ctrl).DataBind();
}
}

--
http://www.petedavis.net
"Bill" <bc****@mcleodusa.net> wrote in message
news:eC**************@TK2MSFTNGP12.phx.gbl...
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).

Nov 15 '05 #2

P: n/a
Thanks a bunch..this looks like it will handle my needs.

"Pete Davis" <pd******@hotmail.com> wrote in message
news:d0******************************@news.meganet news.com...
If all of the controls are on the same form, and assuming they have a
similar name that's different from other drop down lists on the form
(assuming their are others), you can iterate through all the controls on the form, and for all combo boxes that match your name criteria, you could bind the dataset to them. Something like:

DataSet ds = GetMyDataSet();

foreach(Control ctrl in this.Controls)
{
if (ctrl.GetType() == typeof(DropDownList) && ctrl.Name.Substring(1, 4) == "seat")
{
((DropDownList) ctrl).DataSource = ds;
((DropDownList) ctrl).DataBind();
}
}

--
http://www.petedavis.net
"Bill" <bc****@mcleodusa.net> wrote in message
news:eC**************@TK2MSFTNGP12.phx.gbl...
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).


Nov 15 '05 #3

P: n/a
Thanks to all. Your advise has helped allot. But now, you've got me
thinking....

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

What I really would like here is the underlying 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).

I need to retrieve, display and edit all 50 rows of data but I need to
spread them randomly over a floor/booth configuration 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.
"Pete Davis" <pd******@hotmail.com> wrote in message
news:d0******************************@news.meganet news.com...
If all of the controls are on the same form, and assuming they have a
similar name that's different from other drop down lists on the form
(assuming their are others), you can iterate through all the controls on the
form, and for all combo boxes that match your name criteria, you could

bind
the dataset to them. Something like:

DataSet ds = GetMyDataSet();

foreach(Control ctrl in this.Controls)
{
if (ctrl.GetType() == typeof(DropDownList) && ctrl.Name.Substring(1, 4) ==
"seat")
{
((DropDownList) ctrl).DataSource = ds;
((DropDownList) ctrl).DataBind();
}
}

--
http://www.petedavis.net
"Bill" <bc****@mcleodusa.net> wrote in message
news:eC**************@TK2MSFTNGP12.phx.gbl...
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).



Nov 15 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.