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

  • Thread starter Thread starter Bill
  • Start date Start date
B

Bill

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).
 
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();
}
}
 
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.
 
Back
Top