我在ListView裏面有一個DropDownList .. 我想在點擊命令時得到一個數據。 這是我的代碼..如何從ListDown中的DropDownList獲取值?
protected void ListView2_ItemCommand(object sender, ListViewCommandEventArgs e){
string shipmethod = ((DropDownList)e.Item.FindControl("ShippingComapnyDDL")).SelectedValue;
}
但它總是返回空值.. 我使用Google約3小時,並嘗試了很多功能.. ,但不能仍然解決這個bug ..
請幫我傢伙,
UPDATE 這裏是我的aspx頁面
<asp:DropDownList ID="ShippingComapnyDDL" runat="server" SelectedValue='<%# Eval("ShippingCompany") %>'>
<asp:ListItem Text="" Value=""></asp:ListItem>
<asp:ListItem Text="FedEx" Value="FedEx"></asp:ListItem>
<asp:ListItem Text="UPS" Value="UPS"></asp:ListItem>
<asp:ListItem Text="Other" Value="Other"></asp:ListItem>
</asp:DropDownList>
也許是因爲你拼錯公司.. – 2012-04-10 07:24:38
只是另一個原因是魔術字符串是壞:-) – Bridge 2012-04-10 07:26:26
你肯定列表視圖不會在回發 – ViSu 2012-04-10 07:28:24