473,471 Members | 1,778 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Listbox selection to populate another listbox?

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
3 2397
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: James Goodman | last post by:
I have a listbox named sub1 on an asp page. I need to fill this list with values from a table. These are selected based upon the selection of a value/s in another listbox. It was suggested that I...
2
by: Fieldmedic | last post by:
I'm attempting to get an arraylist to display in a Listbox (listbox2). The arraylist is created from selections in a different listbox (listbox1). The 1st listbox has a selection mode of...
1
by: Bish | last post by:
I want to create a .Net page with 2 controls. The 1st is a dropdown being populated from a database. The 2nd control is a listbox which is also populated from the same database but the content is...
2
by: collie | last post by:
Hi, I have 2 listboxes. The first gets populated from the db as soon as the page loads. The second listbox get populated based on the user's selection from the first listbox. However,...
5
by: CCLeasing | last post by:
Hello, I have searched google but can not find a straight forward answer to my problem. Hopefuly someone will be kind enough to offer their expertise. Please forgive if this seems a bit convoluted...
2
by: Chucara | last post by:
Hi, I'm trying to build a simple search in Access. I'll just give a simplified example, as I think I can solve the problem, if you can help me with this subproblem.. I have 2 listboxes -...
9
by: zdrakec | last post by:
Hello all: Clearly, I'm not getting it! Here is the scenario: On a web page, I have two list boxen and a text box. The first listbox is populated at page load time (if it is not a postback)....
0
by: spowel4 | last post by:
VB 2005: Using an xml file as the data source, I need to fill a listbox with data based upon what was selected in a combobox. In other words, my data consists of a list of customers in a...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.