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);
        }
    }

你可能感兴趣的:(treeview)