473,387 Members | 1,669 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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

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
3 3498
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Bill | last post by:
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...
0
by: Patrick | last post by:
I'm working on a contact management application, and need a hand with one aspect... Here's what I want to create: ------------------------------------ A form split into two parts. There is a...
4
by: Iain Kirk | last post by:
Being a bit of a novice any help or pointers would be appreciated. I am building a web page that populates a DropDowList from a table in SQL, for testing purposes i have a simple page that...
8
by: ASP Yaboh | last post by:
I have an ArrayList of data gathered from a database. I want to create a web page from this data by creating a <table>, each cell in each row displays the appropriate data. One of those cells in...
12
by: Bishoy George | last post by:
I have a dataset called ds1 filled with 2 tables Employees and Customers from Northwind database. I have dropdownList called ddLastName with the following properties: ddLastName.DataSource =...
2
by: Gary Shell | last post by:
Sorry for the crosspost, I initially posted this to the microsoft.public.dotnet.languages.vb.data group, but it never showed up there. (Is that newsgroup still active???) I have two datasets...
11
by: ^MisterJingo^ | last post by:
Hi all, I have a form with 4 dropdownlist controls which I populate with data from DB tables. I have a class with a method which constructs a dataset, putting each DB table into a dataset table....
1
by: Jason Wilson | last post by:
I have two dropdownlists that are bound to the same datasource and I have a couple of questions: 1) Because they are bound to the same datasource, I am assuming that they only make 1 round trip...
1
by: MaryamSh | last post by:
Hi, I am creating a Dynamic Search in my application. I create a user control and in Page_load event I create a dynamic dropdownlist and 2 dynamic button (Add,Remove) By pressing Add button...
0
by: MaryamSh | last post by:
Create Dynamic Dropdownlist Controls and related event -------------------------------------------------------------------------------- Hi, I am creating a Dynamic Search in my application. I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.