Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
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:

COL_ID
COL_Name
COL_USER
COL_IMAGE

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?
Reply With Quote
  #2 (permalink)  
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
Default

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
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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



All times are GMT -4. The time now is 04:57 AM.


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.