我想从DropDownList中显示不同的标签输出,按钮下拉列表标记输出C#
select Item on DropDownList and click button to show output in label
谁能帮我这个?
我想从DropDownList中显示不同的标签输出,按钮下拉列表标记输出C#
select Item on DropDownList and click button to show output in label
谁能帮我这个?
protected void Button1_Click(object sender, EventArgs e)
{
lable1.Text=DropDownList1.SelectedValue.ToString();
}
或U可以做
protected void Button1_Click(object sender, EventArgs e)
{
String input=DropDownList1.SelectedIndex >= 0 ? DropDownList1.SelectedItem.ToString() : "";
lable1.Text=input;
}
刚刚写下这button click event
protected void Button1_Click(object sender, EventArgs e) {
label.text = ComboBox.SelectedText;
}
Ÿ-1可以downvoter解释什么是错在这.... –
“你可以使用SelectedText属性来检索或更改ComboBox控件中当前选定的文本。但是,您应该知道,由于用户交互,选择可能会自动更改。例如,如果您在按钮Click事件处理程序中检索SelectedText值,则该值将是一个空字符串。这是因为当输入焦点从组合框移动到按钮时,选择会自动清除。'。此外,OP要求这与一个DropDownList,而不是一个组合框控件... – dtsg
protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text = DropDownList1.SelectedValue;
}
操作需要做的操作按钮点击不在更改.. –
如果它工作标记为你的答案。所以这对其他人有用。 –