Asp.net DropDownList不运行代码隐藏

Asp.net DropDownList不运行代码隐藏,asp.net,Asp.net,hy, 我配置了dropdownlist: 我希望当我从DropDownList中选择一个值时,会发生一个事件 但由于某种原因,代码无法运行 我的代码中有什么问题?是否为ddl设置了AutoPostBack=true 对于您的代码: <asp:DropDownList ID="ddl_filter1" runat="server" Width="120px" DataSourceID="ObjectDataSource1" DataTextField="PLC" DataVal

hy, 我配置了dropdownlist:

我希望当我从DropDownList中选择一个值时,会发生一个事件

但由于某种原因,代码无法运行

我的代码中有什么问题?

是否为ddl设置了AutoPostBack=true

对于您的代码:

<asp:DropDownList ID="ddl_filter1" runat="server" Width="120px" DataSourceID="ObjectDataSource1"
      DataTextField="PLC" DataValueField="PLC" AutoPostBack="true" OnSelectedIndexChanged="ddl_filter1_SelectedIndexChanged" />
您需要将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>  
<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>