数据从数据库里读出来了 关联也实现了
唯一的缺点是每次选择DropDownList 页面就会刷新而且别的表单的字段都值空了,这样填写注册表单很不优化 请高手指教怎么解决这个问题?<asp:DropDownList ID="DropDownList1" runat="server"
                            DataSourceID="SqlDataSource1" DataTextField="Province" DataValueField="Province" meta:resourcekey="DropDownList1Resource1" AutoPostBack="True">
                            </asp:DropDownList>
                            <asp:DropDownList ID="DropDownList2" runat="server" DataSourceID="SqlDataSource2"
                                DataTextField="City" DataValueField="City" meta:resourcekey="DropDownList2Resource1">
                            </asp:DropDownList><asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:renluoConnectionString %>"
                                SelectCommand="SELECT DISTINCT [City], [Province] FROM [Region] WHERE ([Province] = @Province)">
                                <SelectParameters>
                                    <asp:ControlParameter ControlID="DropDownList1" Name="Province" PropertyName="SelectedValue"
                                        Type="String" />
                                </SelectParameters>
                            </asp:SqlDataSource>
                            <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:renluoConnectionString %>"
                            SelectCommand="SELECT DISTINCT [Province] FROM [Region] order by Province asc"></asp:SqlDataSource>

解决方案 »

  1.   

    如果AutoPostBack="false"了,是不执行后台了,估计LZ的关联也不行了
      

  2.   

    利用ajax的控件,实现局部刷新。 EnablePartialRendering="true"实现局部刷新
    <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true" />
            <div>
                <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                    <ContentTemplate>
      

  3.   

    页面刷新,回传页面有些值就会为空,这是asp.net特性
    数据不丢失,就要使用ajax实现局部刷新。用updatepanel
    <asp:ScriptManager ID="ScriptManager1" runat="server">
            </asp:ScriptManager>
            <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                <ContentTemplate>  </ContentTemplate>
            </asp:UpdatePanel>
      

  4.   


    UpdatePanel 是可以解决楼主问题的