TreeView无级级绑定

private void InitTree(TreeNodeCollection Nds, string parentId)
    {
        TreeNode tmpNd;
        IList<ProClass> rows = ProClassService.SelectParent(int.Parse(parentId));
        foreach (ProClass row in rows)
        {
            tmpNd = new TreeNode();
            tmpNd.Value = row.ID.ToString();
            tmpNd.Text = row.Name;
            tmpNd.NavigateUrl = "Product_list.aspx?ProClassId=" + tmpNd.Value;
            Nds.Add(tmpNd);
            if (row.IsLeaf != "1")
                InitTree(tmpNd.ChildNodes, tmpNd.Value);
        }
    }
原文地址:https://www.cnblogs.com/liufei88866/p/1766614.html