2012-05-22 30 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

操作需要做的操作按鈕點擊不在更改.. –