I want to get a selected item from a drop down list, on button click need to show that selected item into a text box.
I haven't tried anything cause i don't know what to do.
I want to get a selected item from a drop down list, on button click need to show that selected item into a text box.
I haven't tried anything cause i don't know what to do.
Just use this code...
Suppose, Button click event:
protected void Button1_Click(object sender, EventArgs e)
{
Textbox1.Text = DropDownList1.SelectedItem.Text.ToString();
}
The following class can give you the general idea of doing what you want.
public class MyClass
{
public MyClass()
{
comboBox = new ComboBox();
button = new Button();
textBox = new TextBox();
button.Click += OnButtonClick;
}
private void OnButtonClick(Object sender, EventArgs e)
{
textBox.Text = comboBox.SelectedItem.ToString();
}
ComboBox comboBox;
Button button;
TextBox textBox;
}