我想根据第一个的索引填充第二个下拉列表。
<asp:ScriptManager ID="sm" runat="server" />
<asp:DropDownList ID="ddl1" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddl1_SelectedIndexChanged">
<asp:ListItem Value="1" />
<asp:ListItem Value="2" />
</asp:DropDownList>
<asp:UpdatePanel ID="up" runat="server">
<Triggers >
<asp:AsyncPostBackTrigger ControlID="ddl1" EventName="SelectedIndexChanged" />
</Triggers>
<ContentTemplate >
<asp:DropDownList ID="ddl2" runat="server">
<asp:ListItem Value="1" />
<asp:ListItem Value="2" />
</asp:DropDownList>
</ContentTemplate>
</asp:UpdatePanel>
代码背后:
protected void ddl1_SelectedIndexChanged(object sender, EventArgs e)
{
ddl2.SelectedIndex = ddl1.SelectedIndex;
}
我收到了完整的帖子。没有ajax在工作。