FormView控件中实现DropDownList+Ajax级联时,整个页面只能有一个ScriptManager控件,且ScripManager控件不能放在FormView里,而应放在Form下,FormView控件之前,否则会出现“只能向页面中添加 ScriptManager 的一个实例”的错误。
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager><!--asp:ScriptManager在这里,一个就足够了--> <div> <asp:UpdatePanel ID="UpdatePanel1" runat="server">> <!--asp:UpdatePanel 1在这里--> <div>
<ContentTemplate> <!--ContentTemplate容器--> <div>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<asp:Button ID="Button1" runat="server" Text="Button"></asp:Button>
</ContentTemplate>
</asp:UpdatePanel> <!--asp:UpdatePanel 1在这里--> <div>
</div>
<div>
<asp:UpdatePanel ID="UpdatePanel2" runat="server" RenderMode="Inline"> <!--asp:UpdatePanel 2在这里--> <div>
<ContentTemplate>
<asp:DropDownList ID="ddlBrand" runat="server" AutoPostBack="true">
<asp:ListItem Text="请选择所属品牌" Value="0" />
</asp:DropDownList>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="ddlCarxID" EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel> <!--asp:UpdatePanel 2在这里--> <div>
<asp:DropDownList ID="ddlCarxID" runat="server">
<asp:ListItem Text="请选择汽车车系" Value="0"></asp:ListItem>
</asp:DropDownList>
</div>
</form>
</body>