Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello everybody,

I want to create a DropDownList that contains (OTHER) option and when the user selects this option, a new textbox will appear besides this DropDownList. How to do that?
Posted

add items to your dropdownlist or combobox
C#
cmbname.Items.AddRange(new object[] {
            "x",
            "y",
            "z",
            "other"});

make a textbox beside dropdownlist and keep textbox invisible
C#
textBox1.Visible = false;


use below code in SelectedIndexChanged event of combobox
C#
if (cmbname.Text == "other")
{
textBox1.Visible = true;
}
 
Share this answer
 
Comments
Dalek Dave 25-Dec-11 15:14pm    
Yep, that is how I would do it.
(Except I would use a case statement).
theanil 25-Dec-11 15:33pm    
thank you Dalek Dave
Handle the selectedIndexChanged event using JavaScript and try something like this.

JavaScript
function onSelectedIndexChanged()
{
   if($("#mySelect").val() == "OTHER")
   {
     $("#textbox").show();
   }
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900