473,226 Members | 1,563 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,226 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 15 '05 #1
3 1709
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

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...
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...
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: 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: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

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.