2013-05-01 110 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>