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

Discussion in 'ASP .Net' started by Bill, Mar 1, 2004.

  1. Bill

    Bill Guest

    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).
    Bill, Mar 1, 2004
    #1
    1. Advertising

  2. 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.
    =?Utf-8?B?UmV6YQ==?=, Mar 1, 2004
    #2
    1. Advertising

  3. 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" <> wrote in message
    news:%23c31j94$...
    > 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).
    >
    >
    >
    Cowboy \(Gregory A. Beamer\), Mar 1, 2004
    #3
  4. Bill

    Bill Guest

    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)" <> wrote in
    message news:OQGUfk5$...
    > 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" <> wrote in message
    > news:%23c31j94$...
    > > 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).
    > >
    > >
    > >

    >
    >
    Bill, Mar 1, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Cowboy \(Gregory A. Beamer\)

    Single Sign on for web apps on same box

    Cowboy \(Gregory A. Beamer\), Nov 5, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    366
    Cowboy \(Gregory A. Beamer\)
    Nov 5, 2003
  2. Grant Merwitz

    Get object from DropDownList bound to object

    Grant Merwitz, Jun 30, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    575
    Robbe Morris [C# MVP]
    Jul 6, 2006
  3. Phillip Vong
    Replies:
    0
    Views:
    401
    Phillip Vong
    Jul 27, 2006
  4. Bill
    Replies:
    2
    Views:
    133
  5. Bill
    Replies:
    1
    Views:
    110
Loading...

Share This Page