2011-11-17 55 views
-1

HY, 我配置dropdownlistDropDownList的不运行的代码背后

<asp:DropDownList ID="ddl_filter1" runat="server" Width="120px" DataSourceID="ObjectDataSource1" 
             DataTextField="PLC" DataValueField="PLC" OnSelectedIndexChanged="ddl_filter1_SelectedIndexChanged" /> 

,我想,当我选择从DropDownList一个值的事件会发生

但somereason后面的代码别跑。

我的代码有什么问题?

+0

请分享您的代码。 –

回答

1

你把AutoPostBack="true"换成ddl了吗?

为了您的代码将是:

<asp:DropDownList ID="ddl_filter1" runat="server" Width="120px" DataSourceID="ObjectDataSource1" 
     DataTextField="PLC" DataValueField="PLC" AutoPostBack="true" OnSelectedIndexChanged="ddl_filter1_SelectedIndexChanged" /> 
+0

是的,我不知道Autopostback是如此重要.. – Aviadjo

1

您需要设置Autopostback为true。

例子:

<asp:DropDownList 
      ID="DropDownList1" 
      runat="server" 
      AutoPostBack="true" 
      OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged" 
      > 
      <asp:ListItem>HyperLink</asp:ListItem> 
      <asp:ListItem>PasswordRecovery</asp:ListItem> 
      <asp:ListItem>PlaceHolder</asp:ListItem> 
      <asp:ListItem>LoginName</asp:ListItem> 
      <asp:ListItem>Label</asp:ListItem> 
     </asp:DropDownList>