日期:2014-05-17  浏览次数:20389 次

求.net Ajax无刷新dropdownlist两级或三级联动代码,数据是从数据库绑定。
我在做联动无刷新,但是一直没有好的代码,我想点country,然后出现city,然后点city,就跳转到city页面,同时,还有一个dropdownlist用来绑定酒店,一跳转到city页面,下面的dropdownlist马上绑定city下的所有酒店。

能不能做到点country,出现city的时候,页面不刷新,只有点击city的时候,跳转city页面才刷新,同时传city的ID,然后下一个dropdownlist获取city的ID ,同时绑定出所有的酒店。

听起来有点绕口,大家给点建议,或者有好的代码,发给我,学习啊,谢谢,
------解决方案--------------------
3级联动无刷新是吧


可以用JS。。

3级联动 无刷新的例子好多。

JS 省市联动

这个也可以
------解决方案--------------------
<asp:ScriptManager ID="ScriptManager1" runat="server">
  </asp:ScriptManager>
  <div>
  <asp:UpdatePanel ID="UpdatePanel1" runat="server">
  <ContentTemplate>
  <asp:DropDownList ID="ddlLB" runat="server" Width="15%" AutoPostBack="True" OnSelectedIndexChanged="ddlLB_SelectedIndexChanged">
  </asp:DropDownList>
  <asp:DropDownList ID="ddlChild" runat="server" Width="20%">
  </asp:DropDownList>
  </ContentTemplate>
  </asp:UpdatePanel>
  </div>  
protected void ddlLB_SelectedIndexChanged(object sender, EventArgs e)
  {
  if(this.ddlLB.SelectedValue!=null)
  {
  BindChild(this.ddlLB.SelectedValue);
  }
  }
------解决方案--------------------
利用ajax控件CascadingDropDown + webservice
前台代码:

<ajaxToolkit:CascadingDropDown ID="CascadingDropDown1" runat="server" TargetControlID="provinceDr"
        ServicePath="GetDLDetailInfo.asmx" ServiceMethod="GetProvince" Category="province"
        PromptValue="0" ParentControlID="" LoadingText="加载省份.." PromptText="请选择省份">
    </ajaxToolkit:CascadingDropDown>
    <ajaxToolkit:CascadingDropDown ID="CascadingDropDown2" runat="server" TargetControlID="cityDr"
        ServicePath="GetDLDetailInfo.asmx" ServiceMethod="GetCityByProvince" Category="city"
        ParentControlID="provinceDr" LoadingText="加载城市.." PromptText="请选择城市">
    </ajaxToolkit:CascadingDropDown>
    <ajaxToolkit:CascadingDropDown ID="CascadingDropDown3" runat="server" TargetControlID="areaDr"
        ServicePath="GetDLDetailInfo.asmx" ServiceMethod="GetAreaByCity" Category="area"
        ParentControlID="cityDr" LoadingText="加载地区.." PromptText="请选择地区">
    </ajaxToolkit:CascadingDropDown>


webservice中对应方法:

using System;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Data;
using System.Collections.Generic;
using System.Collections.Specialized;
using DataAccess;
using AjaxControlToolkit;
using BLL;

/// <summary>
/// GetDLDetailInfo 的摘要说明
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.Web.Script.Serv