473,386 Members | 1,630 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Problem with dropdown list

103 100+
Hi everybody,

I am having a drop down list with items 1,2,3.. and another dropdown list with items apple,orange and lemon..

If i select item 2 in the first dropdown list i need to get orange as the selected item in the second dropdown list.

if i select item 3 in the first drop down list, i need to get lemon in the second drop down list automatically...

I am using asp.net and c#.net....
Please help me..

Regards,
Mathew..
Oct 15 '07 #1
4 1263
Hi,
I think u can specify an select--case for doing that.
Wen u select one item,the corresponding second item wil be selected in ur second dropdownlist.
Another option is to give a if condition.
Try it...

Thanks Jeen
Oct 16 '07 #2
HI,

You dont have to write the "IF" or "SELECT CASE" code to test each selected value..
all you have to do is to set the Autopostback property of the dropdownlist1 equal to TRUE.... then put this code in the dropdownlist1 DropDownList1_SelectedIndexChanged handler:

private void DropDownList1_SelectedIndexChanged(object sender, System.EventArgs e)
{
this.DropDownList2.SelectedIndex=this.DropDownList 1.SelectedIndex;
}

Best Regards,
Ruel

================================================== ======










Hi everybody,

I am having a drop down list with items 1,2,3.. and another dropdown list with items apple,orange and lemon..

If i select item 2 in the first dropdown list i need to get orange as the selected item in the second dropdown list.

if i select item 3 in the first drop down list, i need to get lemon in the second drop down list automatically...

I am using asp.net and c#.net....
Please help me..

Regards,
Mathew..
Oct 16 '07 #3
HI,

You dont have to write the "IF" or "SELECT CASE" code to test each selected value..
all you have to do is to set the Autopostback property of the dropdownlist1 equal to TRUE.... then put this code in the dropdownlist1 DropDownList1_SelectedIndexChanged handler:

private void DropDownList1_SelectedIndexChanged(object sender, System.EventArgs e)
{
this.DropDownList2.SelectedIndex=this.DropDownList 1.SelectedIndex;
}

Best Regards,
Ruel

================================================== ======

This information is very valuable for me too... U specified the solution with one line itself. Thank U.

Jeen
Oct 16 '07 #4
mathewgk80
103 100+
HI,

You dont have to write the "IF" or "SELECT CASE" code to test each selected value..
all you have to do is to set the Autopostback property of the dropdownlist1 equal to TRUE.... then put this code in the dropdownlist1 DropDownList1_SelectedIndexChanged handler:

private void DropDownList1_SelectedIndexChanged(object sender, System.EventArgs e)
{
this.DropDownList2.SelectedIndex=this.DropDownList 1.SelectedIndex;
}

Best Regards,
Ruel

================================================== ======
Hi Ruel,

Thank a lot for your valuable information...

Regards,

Mathew
Oct 16 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: mtz | last post by:
Hi there, It looks like safari has a problem with innerHTML. I have to change a dropdown depending on a selection in another dropdown. When I change the selection in the first dropdown the...
0
by: E . | last post by:
I seem to be getting nowhere with this problem here is the situation. I have a webform with a data grid populated with the results of a table that has only 3 fields. Then below that are 1...
0
by: Manish | last post by:
Hi All, I'm having this problem I hope someone can help provide a solution for it :) I've this dropdown list box in a usercontrol which I'm populating from the database (it's viewstate property...
3
by: msnews.microsoft.com | last post by:
Hi All, I m facing problem in Server Side Validation. For Example The Scenario is I have two fields on the page 1 Country Dropdown List 2 Province Textbox 3 State Dropdown List
13
by: Oliver Hauger | last post by:
Hello, In my html form I show a select-element and if this element is clicked I fill it per JavaScript/DOM with option-elements. I use the following code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD...
2
by: Mike Collins | last post by:
I cannot get the correct drop down list value from a drop down I have on my web form. I get the initial value that was loaded in the list. It was asked by someone else what the autopostback was...
5
by: jung_h_park | last post by:
From: jung_h_park@yahoo.com Newsgroups: microsoft.public.dotnet.framework.aspnet Subject: Dropdown List not retaining its SelectedValue Date: Mon, 26 Jun 2006 21:02:57 -0700 Hello, My...
2
by: sameer | last post by:
Hi guys, thanks in advance. trying to implement some multithreading here : VS 2003 VB.net winforms I have a dropdown on a form which has list of vendors, when the user selects a vendor...
3
by: er1 | last post by:
Hi all, I have created a double dropdown list. Based on the first list selection, second list populates (this works fine). I have a submit button, which when clicked should run a select query...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.