简体   繁体   English

下拉列表以标记输出C#

[英]Dropdownlist to label output C#

I want to show different labels output from DropDownList with button 我想用按钮显示从DropDownList输出的不同标签

select Item on DropDownList and click button to show output in label

Can anyone help me out on this? 有人可以帮我吗?

protected void Button1_Click(object sender, EventArgs e)
{
       Label1.Text = DropDownList1.SelectedValue;
}

just write down this in button click event 只需写下button click event

protected void Button1_Click(object sender, EventArgs e) { 
    label.text = ComboBox.SelectedText;
}
protected void Button1_Click(object sender, EventArgs e)
{
    lable1.Text=DropDownList1.SelectedValue.ToString();
}

or u can do 或者你可以做

   protected void Button1_Click(object sender, EventArgs e)
   {
       String input=DropDownList1.SelectedIndex >= 0 ? DropDownList1.SelectedItem.ToString() : "";
       lable1.Text=input;
   }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM