2012-04-04 25 views
0

我有一個連接到objectdatasource的下拉列表。我怎樣才能得到DataValueField = TypeId?我使用onselectedindexchanged來獲得選定的類型,我怎樣才能用TypeId做同樣的事情?Dropdownlist objectdatasource

<asp:DropDownList ID="DropDownList" runat="server" 
DataSourceID="ObjectDataSource" DataTextField="Type" 
DataValueField="TypeId" AutoPostBack="true" 
onselectedindexchanged="DropDownList_SelectedIndexChanged"> 
         </asp:DropDownList> 

回答

1

要獲取價值是什麼:

int id = int.Parse(DropDownList.SelectedValue); 
1

不確定是否理解....你想獲得選定的值嗎?在這種情況下,這是你必須做的

string typeId = DropDownList.SelectedValue