//子节点

  Expo.Database.SqlGen mycmd = new Expo.Database.SqlGen();
    protected void Page_Load(object sender, EventArgs e)
    {
        IList<string> path = new List<string>();
        GetPath(2, ref path);

        foreach (string s in path) {
            Response.Write(s + "<br/>");
        }
    }


    public void GetPath(int father,ref IList<string> path)
    {
        string strsql = "select id,title,father from t_Area where father=" + father.ToString();
        using (SqlDataReader dr1 = mycmd.ExecuteReader(strsql))
        {
            if (!dr1.HasRows)
                return;
            while (dr1.Read())
            {
                path.Add(dr1["title"].ToString());
                GetPath(Convert.ToInt32(dr1["id"]),ref path);
            }
            dr1.Close();
            dr1.Dispose();
        }
    }

 

 

//父亲节点

 string strsql = @" declare @tempTable TABLE
                            (
                             [id] int,
                             Name varchar(50),
                             Depth int,
                             ParentID int,
                             Rank int
                            )
                            declare @ID int
                       

相关文章: