473,698 Members | 2,426 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1726
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(DropDown List) && ctrl.Name.Subst ring(1, 4) ==
"seat")
{
((DropDownList) ctrl).DataSourc e = ds;
((DropDownList) ctrl).DataBind( );
}
}

--
http://www.petedavis.net
"Bill" <bc****@mcleodu sa.net> wrote in message
news:eC******** ******@TK2MSFTN GP12.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******@hotma il.com> wrote in message
news:d0******** *************** *******@news.me ganetnews.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(DropDown List) && ctrl.Name.Subst ring(1, 4) == "seat")
{
((DropDownList) ctrl).DataSourc e = ds;
((DropDownList) ctrl).DataBind( );
}
}

--
http://www.petedavis.net
"Bill" <bc****@mcleodu sa.net> wrote in message
news:eC******** ******@TK2MSFTN GP12.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******@hotma il.com> wrote in message
news:d0******** *************** *******@news.me ganetnews.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(DropDown List) && ctrl.Name.Subst ring(1, 4) ==
"seat")
{
((DropDownList) ctrl).DataSourc e = ds;
((DropDownList) ctrl).DataBind( );
}
}

--
http://www.petedavis.net
"Bill" <bc****@mcleodu sa.net> wrote in message
news:eC******** ******@TK2MSFTN GP12.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
3640
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 datagrid on the left side that lists names and perhaps a couple of other key fields. The user can click on a record in the datagrid, which should automatically pull up details on that record in the various text boxes and other controls on the right...
4
1549
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 displays a datagrid with the same data, now this does work so i know the data is there but the dropdownlist is empty. If anyone could show me where i'm going wrong i would be very thankful. Here is the code i am using:
3
3512
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 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...
8
2252
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 each row needs a <textarea> control. The background supporting classes are completed, the only task left now is to create the web page. I am at a loss on how to create the table in the page populated by the data. Previously, I would have just...
12
1685
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 = ds1; ddLastName.DataMember = "Employees"; ddLastName.DataTextField = "LastName"; ddLastName.DataBind(); ddLastName.Items.Insert(0,"Select:");
2
1497
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 declared on a single form. The form is instantiated by another form which passes two parameters to the form. These parameters are used to select the data for each of the two datasets. The first dataset loads fine as does the second one. If...
11
1719
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. I then return the DS and bind the tables to the relevant controls. I've been reading that DataReaders are much more efficient than DS's for getting data from the database. So would it better to have 4 methods, each returning a dataReader, or...
1
4655
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 ,another row will be created with the same control (I mean another dropdown and 2 button) and so on. and by pressing Remove button the selecetd row will be removed. I used viewstate to keep my value for postback, I want by changing selectedvalue of...
0
3498
by: MaryamSh | last post by:
Create Dynamic Dropdownlist Controls and related event -------------------------------------------------------------------------------- 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 ,another row will be created with the same control (I mean another dropdown and 2 button) and so on. and by...
0
8678
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9166
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9030
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8899
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7737
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6525
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5861
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
2333
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.