簡體   English   中英

DropDown沒有觸發OnSelectedIndexChanged

[英]DropDown not firing OnSelectedIndexChanged

我有一個帶下拉列表的頁面

   <asp:Content runat="server" ContentPlaceHolderID="ContentPlaceHolder1">
  <asp:DropDownList ID="DropDownList1" runat="server" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
    <asp:ListItem>Cellsite</asp:ListItem>
    <asp:ListItem>Agreement</asp:ListItem>
    <asp:ListItem>Event</asp:ListItem>
    <asp:ListItem>User</asp:ListItem>
</asp:DropDownList>
<asp:Label runat="server" ID="EntityName"></asp:Label>
<ig:WebScriptManager ID="WebScriptManager1" runat="server"></ig:WebScriptManager>
<ig:WebDataGrid ID="EntityGrid" runat="server"  Width="100%">
    <Behaviors>
        <ig:Sorting>
        </ig:Sorting>
    </Behaviors>
</ig:WebDataGrid>

代碼背后是

     protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        EntityName.Text = DropDownList1.SelectedItem.Text;
    }

對於某些原因,標簽永遠不會更新,selectindexchanged的事件根本不會觸發我需要在此事件中添加動態網格。 任何線索?

您需要在下拉列表中添加AutoPostBack

 <asp:DropDownList ID="DropDownList1" runat="server" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged" AutoPostBack="true">

實際上,當您沒有AutoPostBack = true屬性時,您可以確定沒有回發帖子。

set dropdownlist屬性AutoPostBack =“true”

    <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="true" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
    <asp:ListItem>Cellsite</asp:ListItem>
    <asp:ListItem>Agreement</asp:ListItem>
     <asp:ListItem>Event</asp:ListItem>
     <asp:ListItem>User</asp:ListItem>
     </asp:DropDownList>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM