Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Classic ASP Professional For advanced coder questions in ASP 3. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old September 30th, 2015, 03:08 PM
Registered User
Points: 5, Level: 1
Points: 5, Level: 1 Points: 5, Level: 1 Points: 5, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Sep 2015
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Combobox dependent on a table

Hello, I need help to create a combobox dependent
I have a table called "COLLEGE", within her own columns:


How should work:
- The first combo will list all data in the column "col_name";
- When you select any name of the first combo, the second combo should be automatically populated with information from the column "COL_IMAGE"

I am seen in some tutorials that you should use two tables, but in my case I want to use only one. Help me?
Old October 21st, 2015, 02:04 AM
Authorized User
Points: 57, Level: 1
Points: 57, Level: 1 Points: 57, Level: 1 Points: 57, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jan 2010
Posts: 15
Thanks: 0
Thanked 1 Time in 1 Post

Here is aspx code you can refer.

<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:testConnectionString %>"
SelectCommand="SELECT [col_id], [col_name], [col_image] FROM [asptest]"></asp:SqlDataSource>
<asp:DropDownList runat="server" ID="Name" DataSourceID="SqlDataSource1" DataTextField="col_name" DataValueField="col_id"
OnSelectedIndexChanged="Name_SelectedIndexChanged" AutoPostBack="true" />
<asp:DropDownList runat="server" ID="image" DataSourceID="SqlDataSource1" DataTextField="col_image" DataValueField="col_id" />

In code behind of the page, add following function
protected void Name_SelectedIndexChanged(object sender, EventArgs e)
image.SelectedValue = Name.SelectedValue;

Alternatively, this can be achieved using javascript also to avoid a trip to server.

Hope this helps.
Kushal Kaleshwari
Application Architect

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to get value of combobox during Combobox index change in server side harinarayananvp Beginning VB 6 0 October 21st, 2011 01:14 PM
Making ComboBox to display the List from DB table Bjay VB Databases Basics 1 August 1st, 2007 05:55 PM
Table rendering with table & comboBox pazzuzu Java GUI 0 May 9th, 2007 09:04 AM
ComboBox with Data from More than 1 Table rocknrisk Access 7 August 19th, 2005 02:34 AM
Look up value dependent on 2 other variables nkrukovsky Excel VBA 1 September 22nd, 2004 09:51 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.