liandong.aspx:
------------------------------------------

<%@PageLanguage="C#"AutoEventWireup="true"CodeBehind="liandong.aspx.cs"Inherits="WebApplication1.liandong"%><!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><htmlxmlns="http://www.w3.org/1999/xhtml"><headrunat="server"><title>无标题页</title><scriptsrc="script/jquery-1.6.2.js"type="text/javascript"></script><scriptlanguage="javascript"type="text/javascript">$(function(){$("#DropDownList1").change(function(){vardefaultValue="<optionvalue='-1'>--请选择--</option>";$("#DropDownList2").html(defaultValue);$("#DropDownList3").html(defaultValue);showMsg("#DropDownList1","#DropDownList2");})$("#DropDownList2").change(function(){vardefaultValue="<optionvalue='-1'>--请选择--</option>";$("#DropDownList3").html(defaultValue);showMsg("#DropDownList2","#DropDownList3");})})functionshowMsg(sender,receiver){vard1=$(sender).val();$.ajax({type:'get',dataType:"json",url:'liandong.ashx',data:'pid='+d1,success:function(data){$.each(data,function(i,o){varopts="<optionvalue='"+o.id+"'>"+o.name+"</option>";$(receiver).append(opts);})}})}</script></head><body><formid="form1"runat="server"><div><asp:DropDownListID="DropDownList1"runat="server"><asp:ListItemValue="-1">--请选择--</asp:ListItem></asp:DropDownList><asp:DropDownListID="DropDownList2"runat="server"><asp:ListItemValue="-1">--请选择--</asp:ListItem></asp:DropDownList><asp:DropDownListID="DropDownList3"runat="server"><asp:ListItemValue="-1">--请选择--</asp:ListItem></asp:DropDownList></div></form></body></html>

liandong.aspx.cs
-------------------------------------------------------------------------------------------

usingSystem;usingSystem.Collections;usingSystem.Configuration;usingSystem.Data;usingSystem.Linq;usingSystem.Web;usingSystem.Web.Security;usingSystem.Web.UI;usingSystem.Web.UI.HtmlControls;usingSystem.Web.UI.WebControls;usingSystem.Web.UI.WebControls.WebParts;usingSystem.Xml.Linq;namespaceWebApplication1{publicpartialclassliandong:System.Web.UI.Page{protectedvoidPage_Load(objectsender,EventArgse){if(!IsPostBack){stringsql="select*fromt_ldwherepid=0";DataTabledt=DBhelper.query(sql);foreach(DataRowdrindt.Rows){ListItemli=newListItem(dr["name"].ToString(),dr["id"].ToString());this.DropDownList1.Items.Add(li);}}}}}

liandong.ashx.cs

usingSystem;usingSystem.Collections;usingSystem.Data;usingSystem.Linq;usingSystem.Web;usingSystem.Web.Services;usingSystem.Web.Services.Protocols;usingSystem.Xml.Linq;namespaceWebApplication1{///<summary>///$codebehindclassname$的摘要说明///</summary>[WebService(Namespace="http://tempuri.org/")][WebServiceBinding(ConformsTo=WsiProfiles.BasicProfile1_1)]publicclassliandong1:IHttpHandler{publicvoidProce***equest(HttpContextcontext){context.Response.ContentType="text/html";if(!string.IsNullOrEmpty(context.Request.QueryString["pid"])){intpid=Convert.ToInt32(context.Request.QueryString["pid"]);stringsql="select*fromt_ldwherepid="+pid;DataTabledt=DBhelper.query(sql);stringjson_str="";json_str+="[";foreach(DataRowdrindt.Rows){json_str+="{\"id\"";json_str+=":";json_str+="\""+dr["id"].ToString()+"\"";json_str+=",";json_str+="\"name\"";json_str+=":";json_str+="\""+dr["name"].ToString()+"\"";json_str+="}";json_str+=",";}json_str=json_str.Substring(0,json_str.Length-1);json_str+="]";context.Response.Write(json_str);}}publicboolIsReusable{get{returnfalse;}}}}