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

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Pete Davis (pdavis68_at_hotmail.com)
Date: 03/01/04


Date: Mon, 01 Mar 2004 13:13:59 GMT

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" <bcross@mcleodusa.net> wrote in message
news:eC59j74$DHA.1700@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).
>
>


Relevant Pages

  • Re: Need some help on forms
    ... You know with buttons, labels, picture boxes, lists & stuff like that. ... WizardController class to act as the user process component that controls ... In the Form designer select a ListBox that you want to bind to a data ...
    (microsoft.public.dotnet.framework.adonet)
  • RE: ASP.NET 2.0 Dropdownlist EnableViewState=false SelectedIndexCh
    ... model that was implemented in controls in ASP.NET 2.0, ... state to have the control update it's selectedindex between when the control ... reconstructed the dropdownlists on every postback. ... Lists in the ddl's are being rebuilt by overriding OnPreInit on page. ...
    (microsoft.public.dotnet.framework.aspnet.webcontrols)
  • Re: Selecting more than one item from a list.
    ... You mean a Delphi program? ... endless list of controls and non-visual controls in the palette; ... read once, but it's really about the lists of properties, methods, and ... up are writing your own classes when you need them (and equally important, ...
    (comp.lang.pascal.delphi.misc)
  • Re: Would Like VBA that Lists All QAT Controls, Displays their ICon and Description
    ... I think you might have to do it manually, but using a screen capture program such as Snagit from www.techsmith.com would allow you to build up a graphical image of the commands and their icons to which you could add the tooltips. ... Doug Robbins - Word MVP, ... >> Me and a partner are trying to make an index of the QAT controls so ... >> a table of 3 columns that lists out all the Control names, ...
    (microsoft.public.word.vba.beginners)
  • Re: HOW TO: Create a single DataSet bound object used by 50 DropDownList box controls in the same
    ... If all of the 'controls' are in the same scope, ... reference it over and over, ... All web form datavalues will be one of the same 200 ... > Q. Exactly how do I use the same DataSet object in all 50 DropDownList ...
    (microsoft.public.dotnet.framework.adonet)