By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,313 Members | 2,725 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,313 IT Pros & Developers. It's quick & easy.

Listbox selection to populate another listbox?

P: n/a
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
Nov 19 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
TJS
google this

dependent dropdownlists
"Chris Kettenbach" <in**@piasd.net> wrote in message
news:cs********************@giganews.com...
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

Nov 19 '05 #2

P: n/a
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

Nov 19 '05 #3

P: n/a
Cool. I found some examples and they worked great. Thank you.
"TJS" <no****@here.com> wrote in message
news:Ot**************@tk2msftngp13.phx.gbl...
google this

dependent dropdownlists
"Chris Kettenbach" <in**@piasd.net> wrote in message
news:cs********************@giganews.com...
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


Nov 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.