Listbox selection to populate another listbox?

Discussion in 'ASP .Net' started by Chris Kettenbach, Jun 15, 2005.

  1. Hello all,
    Quick question. I have a listbox that is populated by items from a database.
    When the user select something from the list, I want to populate another
    listbox based on the selection in the first.

    Example lstCompany contains a list of company names with the primary key
    field hidden. After user selects a company, I want to pass that primary key
    back to a stored procedure and the 2nd listbox lstEmployees then be
    populated with the employees from the selected company. Are there any
    examples out there? Thanks everybody.

    Chris
     
    Chris Kettenbach, Jun 15, 2005
    #1
    1. Advertising

  2. Chris Kettenbach

    TJS Guest

    google this

    dependent dropdownlists


    "Chris Kettenbach" <> wrote in message
    news:...
    > Hello all,
    > Quick question. I have a listbox that is populated by items from a
    > database. When the user select something from the list, I want to populate
    > another listbox based on the selection in the first.
    >
    > Example lstCompany contains a list of company names with the primary key
    > field hidden. After user selects a company, I want to pass that primary
    > key back to a stored procedure and the 2nd listbox lstEmployees then be
    > populated with the employees from the selected company. Are there any
    > examples out there? Thanks everybody.
    >
    > Chris
    >
     
    TJS, Jun 16, 2005
    #2
    1. Advertising

  3. The concept is simple. Double click on the list box 1 or otherwise add the
    change event to your code and wire it up (Handles with VB.NET += handler with
    C#). Then, you can get the selected item (by Item or Value, depending) and
    pass this to the next sproc. With a small number of items, you can do this
    all with JavaScript, but I would not if you are running a huge number of
    items.

    --
    Gregory A. Beamer
    MVP; MCP: +I, SE, SD, DBA

    ***************************
    Think Outside the Box!
    ***************************


    "Chris Kettenbach" wrote:

    > Hello all,
    > Quick question. I have a listbox that is populated by items from a database.
    > When the user select something from the list, I want to populate another
    > listbox based on the selection in the first.
    >
    > Example lstCompany contains a list of company names with the primary key
    > field hidden. After user selects a company, I want to pass that primary key
    > back to a stored procedure and the 2nd listbox lstEmployees then be
    > populated with the employees from the selected company. Are there any
    > examples out there? Thanks everybody.
    >
    > Chris
    >
    >
    >
     
    =?Utf-8?B?Q293Ym95IChHcmVnb3J5IEEuIEJlYW1lcikgLSBN, Jun 16, 2005
    #3
  4. Cool. I found some examples and they worked great. Thank you.
    "TJS" <> wrote in message
    news:...
    > google this
    >
    > dependent dropdownlists
    >
    >
    > "Chris Kettenbach" <> wrote in message
    > news:...
    >> Hello all,
    >> Quick question. I have a listbox that is populated by items from a
    >> database. When the user select something from the list, I want to
    >> populate another listbox based on the selection in the first.
    >>
    >> Example lstCompany contains a list of company names with the primary key
    >> field hidden. After user selects a company, I want to pass that primary
    >> key back to a stored procedure and the 2nd listbox lstEmployees then be
    >> populated with the employees from the selected company. Are there any
    >> examples out there? Thanks everybody.
    >>
    >> Chris
    >>

    >
    >
     
    Chris Kettenbach, Jun 16, 2005
    #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. Mark
    Replies:
    2
    Views:
    901
  2. Satish
    Replies:
    8
    Views:
    9,657
    Satish
    Mar 31, 2008
  3. Euan

    Populate label from Datagrid selection

    Euan, Apr 15, 2005, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    187
    Elton Wang
    Apr 16, 2005
  4. Enjoy Life
    Replies:
    2
    Views:
    277
    Roland Hall
    Feb 23, 2005
  5. Replies:
    1
    Views:
    211
Loading...

Share This Page