Jerry的专栏

QQ: 26010284 MSN: cuijian1900@hotmail.com

TreeView递归生成树

       protected void initTree()
        {
            TreeNode rootnode = new TreeNode("所有小区", "0");
            CreateChildNode(0, rootnode);

            treeAddress.Nodes.Add(rootnode);
            treeAddress.CollapseAll();
        }

        protected void CreateChildNode(int parentID, TreeNode node)
        {
            SqlDataReader dr = BLL.Address.GetChild(parentID);
            using (dr)
            {
                while (dr.Read())
                {
                    TreeNode tn = new TreeNode();
                    tn.Text = dr["AddName"].ToString();
                    tn.Value = dr["AddID"].ToString();
                    node.ChildNodes.Add(tn);
                    CreateChildNode(ConvertUtils.ToInt(dr["AddID"].ToString(), -1), tn);
                }
            }
        }
 

阅读更多
上一篇C# 取得某个月第一天和最后天时间
下一篇Javascript Checkbox全选练习
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭