static public String Titl;
現在使用簡單的編程語言,假設我的窗體上有一個下拉列表。當我調試,我發現了一個id dropdownlist1是dropdowlist書面將從下拉列表中選擇的值轉換爲字符串變量c#
dropdownlist1.text;
時包含了我在下拉菜單中選擇的值。然而,當我做這樣的事情:
titl = dropdownlist1.text;
我沒有得到titl變量的值。需要幫助。謝謝!
static public String Titl;
現在使用簡單的編程語言,假設我的窗體上有一個下拉列表。當我調試,我發現了一個id dropdownlist1是dropdowlist書面將從下拉列表中選擇的值轉換爲字符串變量c#
dropdownlist1.text;
時包含了我在下拉菜單中選擇的值。然而,當我做這樣的事情:
titl = dropdownlist1.text;
我沒有得到titl變量的值。需要幫助。謝謝!
檢查這一點,如果你想text..then
title=dropdownlist1.selecteditem.text;
,如果你想要的值,然後
title=dropdownlist1.selecteditem.value;
Title = !string.IsNullorEmpty(dropdownlist1.SelectedItem.Text) ?
dropdownlist1.SelectedITem.Text : "";
Titl = dropdownlist1.SelectedValue;
作品!謝謝!
int selectedIndex=dropdownlist1.SelectedIndex;//get index
string selectedText=dropdownlist1.SelectedItem.Text;//get text
string selectedValue=dropdownlist1.SelectedItem.Value;//get value
Shree Khanal:那不會解決任何問題...... – Rupo 2012-08-03 07:46:31