By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,313 Members | 1,145 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,313 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 18 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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.
Nov 18 '05 #2

P: n/a
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!
************************************************** ********************
"Bill" <bc****@mcleodusa.net> wrote in message
news:%2****************@tk2msftngp13.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 18 '05 #3

P: n/a
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?

"Cowboy (Gregory A. Beamer)" <No************@comcast.netNoSpamM> wrote in
message news:OQ**************@TK2MSFTNGP10.phx.gbl...
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!
************************************************** ********************
"Bill" <bc****@mcleodusa.net> wrote in message
news:%2****************@tk2msftngp13.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 18 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.