1

我有一个带有下拉列表的页面

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

由于某种原因,标签永远不会更新,事件 selectedindexchanged 根本没有触发我需要在这个事件中添加一个动态网格。有什么线索吗?

4

2 回答 2

5

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

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

当您没有 AutoPostBack=true 属性时,您实际上可以说没有回发。

于 2013-05-01T18:52:22.307 回答
0

设置下拉列表属性 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>
于 2013-05-01T18:53:47.000 回答