这个省市县的 联动,我想用updatepanel来实现局部刷新,怎么做啊?
这三个要拖三个 updatepanel控件吗?
我拖了一个出现这个错误
ID 为“UpdatePanel1”的控件需要页面上有 ScriptManager。ScriptManager 必须在任何需要它的控件之前出现。 
我就加了, <tr class="b">
    <td class="style1" align="center">请选择省份</td>
    <td class="style2">
         <asp:ScriptManager ID="ScriptManager1" runat="server">
            </asp:ScriptManager>
             <asp:UpdatePanel ID="UpdatePanel1" runat="server">
               <ContentTemplate>
               <asp:DropDownList ID="ddlprovince" runat="server" 
            onselectedindexchanged="ddlprovince_SelectedIndexChanged"
            Width="185px" AutoPostBack="True">
               </asp:DropDownList>
              </ContentTemplate>
          </asp:UpdatePanel>
</td>
</tr>
<tr class="b" id="city" runat="server">
    <td align="center" class="style1">请选择市</td>
    <td class="style2">
     <asp:DropDownList ID="ddlcity" runat="server"  Width="185px" AutoPostBack="True" 
            onselectedindexchanged="ddlcity_SelectedIndexChanged">
        </asp:DropDownList>
    </td>
</tr>
<tr class="b" id="country" runat="server">
    <td class="style1" align="center">请选择县</td>
    <td class="style2">
    <asp:DropDownList ID="ddlcountry" runat="server" Width="185px" AutoPostBack="True" 
            onselectedindexchanged="ddlcountry_SelectedIndexChanged">
        </asp:DropDownList>
    </td>
</tr>
但是选择省,显示都没刷新啊。

解决方案 »

  1.   

    updatepanel本来就是无刷新用的啊
      

  2.   

    选择省要显示对应的市?
    你的市县等并没有放在updatepanel里面,当然没反应
      

  3.   

    把省,市,县等全放到updatepannel里面
      

  4.   

    三个放在一个updatepanel中吗?要设置相关属性吗?
      

  5.   

    用一个updatepanel将那三个都放进这个updatepanel里面就行了
      

  6.   

    没有用updatepannel的时候你是怎么设置的就怎么设置,然后添加个updatepanel,并把之前的所有代码放到updatepanel里面就可以了.
      

  7.   

     <tr class="b">
        <td class="style1" align="center">请选择省份</td>
        <td class="style2">
             <asp:ScriptManager ID="ScriptManager1" runat="server">
                </asp:ScriptManager>
                 <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                   <ContentTemplate>
                   <asp:DropDownList ID="ddlprovince" runat="server" 
                onselectedindexchanged="ddlprovince_SelectedIndexChanged"
                Width="185px" AutoPostBack="True">
                   </asp:DropDownList>
                  </ContentTemplate>
             </td>
    </tr>
    <tr class="b" id="city" runat="server">
        <td align="center" class="style1">请选择市</td>
        <td class="style2">
         <asp:DropDownList ID="ddlcity" runat="server"  Width="185px" AutoPostBack="True" 
                onselectedindexchanged="ddlcity_SelectedIndexChanged">
            </asp:DropDownList>
        </td>
    </tr>
    <tr class="b" id="country" runat="server">
        <td class="style1" align="center">请选择县</td>
        <td class="style2">
        <asp:DropDownList ID="ddlcountry" runat="server" Width="185px" AutoPostBack="True" 
                onselectedindexchanged="ddlcountry_SelectedIndexChanged">
            </asp:DropDownList>
        </td>
    </tr>
     </asp:UpdatePanel>
      

  8.   

     <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    这个控件要怎么办呢?
      

  9.   

    <body>
    <asp:ScriptManager ID="ScriptManager1" runat="server"> 
    </asp:ScriptManager> 
    <asp:updatepanel... >
    <...省>
    <...市>
    ...
    </asp:updatepannel>
    <body>
      

  10.   

    这放在最外面 里面放updatepanel
      

  11.   

    <asp:ScriptManager ID="ScriptManager1" runat="server"> 
    </asp:ScriptManager> 这个还是原样
      

  12.   

    要在updatePanel 前面 先把ScriptManager  拖上去
      

  13.   

    错误“System.Web.UI.UpdatePanel”内不允许包含文字内容(“添加总代理</td>  </tr>  请选择省份</td>          </asp:DropDownList>              </td>  </tr>        请选择市</td>                       </asp:DropDownList>      </td>  </tr>        请选择县</td>                      </asp:DropDownList>      </td>  </tr>”)。
      

  14.   

    省市县三个下拉选单一般都是放在一起的,直接三个drodownlist放一起就可以了,表格那些布局可以删掉.
      

  15.   

    不行啊,我的dropdownlist都是放在tr中的啊 <tr class="b">
        <td class="style1" align="center">请选择省份</td>
        <td class="style2">
                   <asp:DropDownList ID="ddlprovince" runat="server" 
                onselectedindexchanged="ddlprovince_SelectedIndexChanged"
                Width="185px" AutoPostBack="True">
                   </asp:DropDownList>
    </td>
    </tr>
    <tr class="b" id="city" runat="server">
        <td align="center" class="style1">请选择市</td>
        <td class="style2">
         <asp:DropDownList ID="ddlcity" runat="server"  Width="185px" AutoPostBack="True" 
                onselectedindexchanged="ddlcity_SelectedIndexChanged">
            </asp:DropDownList>
        </td>
    </tr>
    <tr class="b" id="country" runat="server">
        <td class="style1" align="center">请选择县</td>
        <td class="style2">
        <asp:DropDownList ID="ddlcountry" runat="server" Width="185px" AutoPostBack="True" 
                onselectedindexchanged="ddlcountry_SelectedIndexChanged">
            </asp:DropDownList>
        </td>
    </tr>
      

  16.   

    这个控件紧贴着updatepanel放
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
       <ContentTemplate>
           <asp:DropDownList ID="ddlprovince" runat="server" 
                onselectedindexchanged="ddlprovince_SelectedIndexChanged"
                Width="185px" AutoPostBack="True">
            </asp:DropDownList>
        </ContentTemplate>
     </asp:UpdatePanel>
    不必放在updatepanel里面 你要实现局部刷新的代码必须放在UpdatePanel里面
      

  17.   

    把放省,市,县的tr   td合并
    <table>
    <tr>
    <td>
    </td>
    </tr>
    <tr>
    <td>
    <asp:ScriptManager ID="ScriptManager1" runat="server"> 
    </asp:ScriptManager>
    <asp:updatepanel...>
    省:<asp:drodownlist..../>
    市:<asp:drodownlist..../>
    县:<asp:drodownlist..../>
    </asp:updatepanel>
    </td>
    </tr>
    </table>
      

  18.   

    建议直接用微软的级联控制Ajax控件CascadingDropDown,很好用的。建议到http://download.csdn.net/source/1564214这个地址下载,应该会很有帮助
      

  19.   

    如果是vs2005,记得注意web.config配置~~~
      

  20.   

    updatemanage放在最外面比如:
    <form>
    <updatemanage>
    </updatemanage><updatepanal>
    这里面就放你不刷新的数据就可以了
    </updatepanal></form>
      

  21.   

    <asp:ScriptManager ID="ScriptManager2" runat="server">
            </asp:ScriptManager>
            <asp:UpdatePanel ID="UpdatePanel2" runat="server">
                <ContentTemplate>
                    <table>
                        <tr class="b">
                            <td class="style1" align="center">
                                请选择省份
                            </td>
                            <td class="style2">
                                <asp:DropDownList ID="ddlprovince " runat="server" OnSelectedIndexChanged="ddlprovince_SelectedIndexChanged"
                                    Width="185px" AutoPostBack="True">
                                </asp:DropDownList>
                            </td>
                        </tr>
                        <tr class="b" id="city" runat="server">
                            <td align="center" class="style1">
                                请选择市
                            </td>
                            <td class="style2">
                                <asp:DropDownList ID="ddlcity " runat="server" Width="185px" AutoPostBack="True"
                                    OnSelectedIndexChanged="ddlcity_SelectedIndexChanged">
                                </asp:DropDownList>
                            </td>
                        </tr>
                        <tr class="b" id="country" runat="server">
                            <td class="style1" align="center">
                                请选择县
                            </td>
                            <td class="style2">
                                <asp:DropDownList ID="ddlcountry" runat="server" Width="185px" AutoPostBack="True">
                                </asp:DropDownList>
                            </td>
                        </tr>
                    </table>
                </ContentTemplate>
            </asp:UpdatePanel>
    楼主,这样写就可以了。
      

  22.   


    <asp:ScriptManager ID="ScriptManager2" runat="server"> 
            </asp:ScriptManager> 
            <asp:UpdatePanel ID="UpdatePanel2" runat="server"> 
                <ContentTemplate> 
                    <table> 
                        <tr class="b"> 
                            <td class="style1" align="center"> 
                                请选择省份 
                            </td> 
                            <td class="style2"> 
                                <asp:DropDownList ID="ddlprovince " runat="server" OnSelectedIndexChanged="ddlprovince_SelectedIndexChanged" 
                                    Width="185px" AutoPostBack="True"> 
                                </asp:DropDownList> 
                            </td> 
                        </tr> 
                        <tr class="b" id="city" runat="server"> 
                            <td align="center" class="style1"> 
                                请选择市 
                            </td> 
                            <td class="style2"> 
                                <asp:DropDownList ID="ddlcity " runat="server" Width="185px" AutoPostBack="True" 
                                    OnSelectedIndexChanged="ddlcity_SelectedIndexChanged"> 
                                </asp:DropDownList> 
                            </td> 
                        </tr> 
                        <tr class="b" id="country" runat="server"> 
                            <td class="style1" align="center"> 
                                请选择县 
                            </td> 
                            <td class="style2"> 
                                <asp:DropDownList ID="ddlcountry" runat="server" Width="185px" AutoPostBack="True"> 
                                </asp:DropDownList> 
                            </td> 
                        </tr> 
                    </table> 
                </ContentTemplate> 
            </asp:UpdatePanel> 
    应该没有问题了。
      

  23.   

    <form id="form1" runat="server" >
    <asp:ScriptManager ID="ScriptManager1" runat="server" EnableScriptGlobalization="true" EnableScriptLocalization="true">
    </asp:ScriptManager>
    放到最前面去,Form的后面
      

  24.   

    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
             <asp:UpdatePanel ID="UpdatePanel1" runat="server">
               <ContentTemplate>
                <table>
                    <tr class="b">
                        <td class="style1" align="center">请选择省份</td>
                        <td class="style2">                       <asp:DropDownList ID="ddlprovince" runat="server" 
                        onselectedindexchanged="ddlprovince_SelectedIndexChanged"
                        Width="185px" AutoPostBack="True">
                           </asp:DropDownList>
                         
                        </td>
                    </tr>
                    <tr class="b" id="city" runat="server">
                        <td align="center" class="style1">请选择市</td>
                        <td class="style2">
                        <asp:DropDownList ID="ddlcity" runat="server"  Width="185px" AutoPostBack="True" 
                        onselectedindexchanged="ddlcity_SelectedIndexChanged">
                        </asp:DropDownList>
                        </td>
                    </tr>
                    <tr class="b" id="country" runat="server">
                        <td class="style1" align="center">请选择县</td>
                        <td class="style2">
                        <asp:DropDownList ID="ddlcountry" runat="server" Width="185px" AutoPostBack="True" 
                        onselectedindexchanged="ddlcountry_SelectedIndexChanged">
                        </asp:DropDownList>
                        </td>
                    </tr>            </table>
            </ContentTemplate>
            </asp:UpdatePanel>
    </form>
      

  25.   


     <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
                                                            <ContentTemplate>
                                                                <asp:DropDownList ID="DDL_PRO" runat="server" AutoPostBack="True" OnSelectedIndexChanged="DDL_PRO_SelectedIndexChanged"
                                                                    Width="150px">
                                                                </asp:DropDownList>
                                                                <asp:DropDownList ID="DDL_City" runat="server" AutoPostBack="True" OnSelectedIndexChanged="DDL_City_SelectedIndexChanged"
                                                                    Width="150px">
                                                                </asp:DropDownList>
                                                                <asp:DropDownList ID="DDL_Dis" runat="server" Width="150px">
                                                                </asp:DropDownList>
                                                            </ContentTemplate>
                                                        </asp:UpdatePanel>
      

  26.   


       public void bind()
        {
            DBClass db = new DBClass();
            //---------------------------------绑定省到DDL_PRO
            DataTable dt1 = db.GetRecords("select * from S_Province");
            this.DDL_PRO.DataSource = dt1;
            this.DDL_PRO.DataTextField = "ProvinceNAME";
            this.DDL_PRO.DataValueField = "ProvinceID";
            this.DDL_PRO.DataBind();
            //---------------------------------绑定市到DDL_City
            DataTable dt2 = db.GetRecords("select * from S_city where ProvinceID=" + DDL_PRO.SelectedValue);
            this.DDL_City.DataSource = dt2;
            this.DDL_City.DataTextField = "CityName";
            this.DDL_City.DataValueField = "CityID";
            this.DDL_City.DataBind();
            //---------------------------------绑定县到DDL_Dis
            DataTable dt3 = db.GetRecords("select * from S_District where CityID=" + DDL_City.SelectedValue);
            if (dt3.Rows.Count == 0)
            {
                DDL_Dis.Visible = false;
            }
            else
            {
                DDL_Dis.Visible = true;
                this.DDL_Dis.DataSource = dt3;
                this.DDL_Dis.DataTextField = "DistrictName";
                this.DDL_Dis.DataValueField = "DistrictID";
                this.DDL_Dis.DataBind();
            }
            if (DDL_PRO.SelectedItem.Text == DDL_City.SelectedItem.Text)
            {
                DDL_City.Visible = false;
            }
            else
            {
                DDL_City.Visible = true;
            }
        }    protected void DDL_PRO_SelectedIndexChanged(object sender, EventArgs e)
        {
            DBClass db = new DBClass();
            DataTable dt2 = db.GetRecords("select * from S_city where ProvinceID=" + DDL_PRO.SelectedValue);
            this.DDL_City.DataSource = dt2;
            this.DDL_City.DataTextField = "CityName";
            this.DDL_City.DataValueField = "CityID";
            this.DDL_City.DataBind();        DataTable dt3 = db.GetRecords("select * from S_District where CityID=" + DDL_City.SelectedValue);
            if (dt3.Rows.Count == 0)
            {
                DDL_Dis.Visible = false;
            }
            else
            {
                DDL_Dis.Visible = true;
                this.DDL_Dis.DataSource = dt3;
                this.DDL_Dis.DataTextField = "DistrictName";
                this.DDL_Dis.DataValueField = "DistrictID";
                this.DDL_Dis.DataBind();
            }
            if (DDL_PRO.SelectedItem.Text == DDL_City.SelectedItem.Text)
            {
                DDL_City.Visible = false;
            }
            else
            {
                DDL_City.Visible = true;
            }
        }
        protected void DDL_City_SelectedIndexChanged(object sender, EventArgs e)
        {
            DBClass db = new DBClass();
            DataTable dt3 = db.GetRecords("select * from S_District where CityID=" + DDL_City.SelectedValue);
            if (dt3.Rows.Count == 0)
            {
                DDL_Dis.Visible = false;
            }
            else
            {
                DDL_Dis.Visible = true;
                this.DDL_Dis.DataSource = dt3;
                this.DDL_Dis.DataTextField = "DistrictName";
                this.DDL_Dis.DataValueField = "DistrictID";
                this.DDL_Dis.DataBind();
            }
        }
        protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
        {
            table2.Visible = CheckBox1.Checked;
        }
      

  27.   

    <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
                                                            <ContentTemplate>
                                                                <asp:DropDownList ID="DDL_PRO" runat="server" AutoPostBack="True" OnSelectedIndexChanged="DDL_PRO_SelectedIndexChanged"
                                                                    Width="150px">
                                                                </asp:DropDownList>
                                                                <asp:DropDownList ID="DDL_City" runat="server" AutoPostBack="True" OnSelectedIndexChanged="DDL_City_SelectedIndexChanged"
                                                                    Width="150px">
                                                                </asp:DropDownList>
                                                                <asp:DropDownList ID="DDL_Dis" runat="server" Width="150px">
                                                                </asp:DropDownList>
                                                            </ContentTemplate>
                                                        </asp:UpdatePanel>