2012-05-22 29 views

回答

0
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; 
    } 
+0

如果它工作标记为你的答案。所以这对其他人有用。 –

1

刚刚写下这button click event

protected void Button1_Click(object sender, EventArgs e) { 
    label.text = ComboBox.SelectedText; 
} 
+0

Ÿ-1可以downvoter解释什么是错在这.... –

+1

“你可以使用SelectedText属性来检索或更改ComboBox控件中当前选定的文本。但是,您应该知道,由于用户交互,选择可能会自动更改。例如,如果您在按钮Click事件处理程序中检索SelectedText值,则该值将是一个空字符串。这是因为当输入焦点从组合框移动到按钮时,选择会自动清除。'。此外,OP要求这与一个DropDownList,而不是一个组合框控件... – dtsg

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

操作需要做的操作按钮点击不在更改.. –