2013-05-01 74 views
1

我有一個網頁下拉列表下拉沒有發射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; 
    } 

對於somereason標籤從不更新的SelectedIndexChanged事件在不觸發所有我需要在這個事件中添加一個動態網格。任何線索?

+4

設置下拉屬性的AutoPostBack = 「真」 – 2013-05-01 18:51:46

回答

4

您需要添加的AutoPostBack的下拉

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

實際上,你可以告訴大家,沒有後回來時,你不必將AutoPostBack = true屬性。

0

集下拉列表屬性的AutoPostBack = 「真」

<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>