2013-03-21 68 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

相关问题