2013-03-21 72 views
0

我正在使用jquery simple modaljquery modal沒有從asp下拉列表中選擇值

function showCancelledModal() { 
    $('#<%=CancelledPanel.ClientID %>').modal({ appendTo: 'form' }); 
} 

<asp:Panel ID="CancelledPanel" runat="server" Style="display: none"> 
    <asp:DropDownList ID="CancelledDropDownList" runat="server"></asp:DropDownList> 
    <asp:Button ID="CancelButton" runat="server" Text="Cancel" OnClick="CancelButton_Click" /> 
</asp:Panel> 

protected void CancelButton_Click(object sender, EventArgs e) 
{ 
    var item = CancelledDropDownList.SelectedItem.Value; 
    //CancelReservation(strReservationId); 
} 

問題是,在我的按鈕單擊事件它似乎並沒有得到下拉列表中選定的值。它每次只默認第一個值。我將下拉列表綁定到頁面加載事件中的表格。

任何人都可以提供任何建議嗎?

+0

提示:你重新綁定你的DDL後,復位selectedItem屬性。 – 2013-03-21 14:33:12

回答

1

我無法發表任何評論(可能因爲我是新來賓,沒有聲望!)。 所以,它在這裏... 這是非常基本的,但是你確定你沒有在每一個回發數據綁定下拉列表?

即。忘記是這樣的:

private void Page_Load() 
{ 
    if (!IsPostBack) 
     CancelledDropDownList.DataBind(); // this method will reset the SelectedValue 
} 

乾杯

+0

自從我有這個noob問題以來,它已經變老了!但是,是的,我每回發一次都重新綁定ddl。 – tqrecords 2015-06-01 19:40:25

相關問題