asp:DropDownList不刷新页面问题

相信很多小伙伴做数据联动碰到asp:DropDownList刷新页面都会很苦恼。

废话不多说,看法宝。

<asp:DropDownList ID="ddlcountry" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlcountry_SelectedIndexChanged">
                            </asp:DropDownList>

由于设置了 AutoPostBack="true" 属性,若为fals,后台不更新数据列表:很烦。

查阅了大量网址,终于找到了不刷新的办法。

asp中UpdatePanel标签,完美的解决了这个问题。

                    <asp:ScriptManager ID="ScriptManager1" runat="server">
                    </asp:ScriptManager>
                    <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="false">
                        <ContentTemplate>
                            <asp:DropDownList ID="ddlcountry" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlcountry_SelectedIndexChanged">
                            </asp:DropDownList>         
                        </ContentTemplate>
                    </asp:UpdatePanel>
                    <asp:UpdatePanel ID="UpdatePanel2" runat="server">
                        <ContentTemplate>
                            <asp:DropDownList ID="ddpostway" runat="server">
                            </asp:DropDownList>
                        </ContentTemplate>
                    </asp:UpdatePanel>

后端数据绑定我就不解释了。

原文地址:https://www.cnblogs.com/jstblog/p/14785424.html