[英]Place selected item from drop down list in to a text box
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;
}
I Have One TextBox
And DropDownList1
And Button
我有一个
TextBox
和DropDownList1
和Button
To Event ClickButton Write This Code 到事件ClickButton编写此代码
TextBox1.Text = DropDownList1.Text;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.