<html xmlns="http://www.w3.org/1999/xhtml"> 
   
  <head id="Head1" runat="server"> 
   
<script type="text/javascript">
function XmlPost(str)
{
  var webFileUrl=""; 
  document.all("<% =Lbx_ClassThree.ClientID %>").length=0; 
  if(str==1)
  {
  webFileUrl = "?oneid=" + document.all("<% =Lbx_ClassOne.ClientID %>").value; 
  document.all("<% =Lbx_ClassTwo.ClientID %>").length=0; 
  }
  else
  {
  webFileUrl = "?oneid=" + document.all("<% =Lbx_ClassOne.ClientID %>").value+"&twoid="+document.all("<% =Lbx_ClassTwo.ClientID %>").value; 
  }
  var result = ""; 
  var xmlHttp = new ActiveXObject("MSXML2.XMLHTTP"); 
  xmlHttp.open("Post", webFileUrl, false); 
  xmlHttp.send(""); 
  result = xmlHttp.responseText; 
  if(result != "")
  {
  var piArray = result.split(","); 
  if(str==1)
  {
  for(var i=0; i<piArray.length; i++)
  {
  var ary1 = piArray[i].toString().split("|"); 
  document.all("<% =Lbx_ClassTwo.ClientID %>").options.add(new Option(ary1[1].toString(),ary1[0].toString())); 
   }
  }
  else
  {
  for(var i=0; i>piArray.length; i++)
  {
  var ary1 = piArray[i].toString().split("|"); 
  document.all("<% =Lbx_ClassThree.ClientID %>").options.add(new Option(ary1[1].toString(),ary1[0].toString())); 
  } 
  }
  }
}
  </script>
   
  </head> 
   
  <body> 
   
   <form id="form1" runat="server"> 
<asp:ListBox ID="Lbx_ClassOne" runat="server"></asp:ListBox>  <asp:ListBox ID="Lbx_ClassTwo" runat="server" ></asp:ListBox>
  <asp:ListBox ID="Lbx_ClassThree" runat="server" ></asp:ListBox>    
   </form> 
   
  </body> 
   
  </html>
。cs文件
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;public partial class Member_liandong_liandong : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string strOneid = "", strTwoid = "";
        if (Request["oneid"] != null && Request["oneid"].ToString() != "")
        {
            strOneid = Request["oneid"].ToString();
        }
        if (Request["twoid"] != null && Request["twoid"].ToString() != "")
        {
            strTwoid = Request["twoid"].ToString();
        }
        if (strOneid != "")
        {
            Lbx_Class_Bind(strOneid, strTwoid);
            //Lbx_Class_Bind(strOneid, strTwoid);
        }
        if (!this.IsPostBack)
        {
            Lbx_ClassOne_Bind();
            Lbx_ClassOne.Attributes.Add("onchange", "XmlPost(1)");
            Lbx_ClassTwo.Attributes.Add("onchange", "XmlPost(2)");
                   }
    }
    private void Lbx_ClassOne_Bind()
    {
        string strSQL;
        strSQL = "select * from area where oneid<>0 and twoid=0 and threeid=0 order by sort";
        Lbx_ClassOne.DataSource =Class1.GetDataReader(strSQL); //此处为我写的一个取DataReader对象的类
        Lbx_ClassOne.DataTextField = "areaname";
        Lbx_ClassOne.DataValueField = "oneid";
        Lbx_ClassOne.DataBind();
    }
    private void Lbx_Class_Bind(string oneid, string twoid)    {
        string strSQL = "", idname = "";
        if (oneid != "" && twoid == "")
        {
            strSQL = "select * from area where twoid<>0 and threeid=0 and oneid=" + oneid + " order by sort";
            idname = "twoid";
        }
         if (oneid != "" && twoid != "")        {
            strSQL = "select * from area where threeid<>0 and oneid=" + oneid + " and twoid=" + twoid + " order by sort";
            idname = "threeid";         
        }
        string mystr = "";
        IDataReader dr = Class1.GetDataReader(strSQL); //此处为我写的一个取DataReader对象的类
        while (dr.Read())
        {
            mystr += "," + dr[idname].ToString() + "|" + dr["areaname"].ToString();
        }
        if (mystr != "")
        {
            mystr = mystr.Substring(1);
        }
        dr.Close();
        this.Response.Write(mystr);
        this.Response.End();
    }
}