473,545 Members | 2,679 Online
Bytes | Software Development & Data Engineering Community
+ 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 2408
TJS
google this

dependent dropdownlists
"Chris Kettenbach" <in**@piasd.net > wrote in message
news:cs******** ************@gi ganews.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.co m> wrote in message
news:Ot******** ******@tk2msftn gp13.phx.gbl...
google this

dependent dropdownlists
"Chris Kettenbach" <in**@piasd.net > wrote in message
news:cs******** ************@gi ganews.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
4925
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 use a hidden iframe on my main page, & carry out the processing inside the frame, using jscript. If I open the page in a browser, & make a...
2
4210
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 MultiExtended. Once the selection has been made in the 1st ListBox, the user clicks on a button to generate the arraylist using the values selected. Then...
1
8590
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 dependent upon a selection from the dropdown control. I have no DB issues but being new to ..Net want a slick way to refresh my listbox control...
2
2907
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, currently the code is such that with each selection there is a postback. We want to avoid it using filter and javascript. I am not using ADO.NET but adodbc...
5
2845
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 but this is probabally a reflection of my not clear understanding of the mechanics behind what i'm trying to achieve. Please bear with it I really...
2
2348
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 - "Region" and "Country". "Region" supports extended multiple select. I want the Country listbox to populate with all countries in all of the selected...
9
3205
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). This listbox has AutoPostback = True. When the user selects an item from this list, the second listbox is populated with more items relevant to this...
0
1270
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 combobox; once a particular customer is selected I need to populate a listbox with data specific to the selected customer. A sample layout of the xml...
0
7496
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7428
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7685
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7784
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6014
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5354
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5071
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3467
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1916
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 we have to send another system

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.