码迷,mamicode.com
首页 > 其他好文 > 详细

DevExpress TreeList利用递归绑定数据

时间:2014-08-02 09:55:43      阅读:377      评论:0      收藏:0      [点我收藏+]

标签:des   style   blog   color   数据   for   ar   div   

 private void TreeListBind(DataTable dt, int p)
        {
            treeList1.Nodes.Clear();
            if (dt.Rows.Count < 1)
                return;
            DataView dv = new DataView(dt);
            dv.RowFilter = "ParentFieldName=" + p;
            if (dv.Count < 1)
                return;
            TreeListNode Node = treeList1.AppendNode("id", null);
            Node.SetValue(treeListColumn1,"第一个节点名");
            foreach (DataRowView dv1 in dv)
            {
                TreeListNode tn = treeList1.AppendNode(dv1["KeyFieldName"], Node);
                tn.SetValue(treeListColumn1, dv1["NodeName"]);
                tn.Tag = dv1;
                GetCentralChild(dt,tn, Convert.ToInt16(dv1["KeyFieldName"]));
            }
        }

        private void GetCentralChild(DataTable dt, TreeListNode tn, int p)
        {
            DataView dv = new DataView(dt);
            dv.RowFilter = "ParentFieldName=" + p;
            if (dv.Count < 1)
                return;
            foreach (DataRowView dv1 in dv)
            {
                TreeListNode tns = tn.TreeList.AppendNode(dv1["KeyFieldName"], tn);
                //TreeListNode tn = treeList1.AppendNode(dv1["KeyFieldName"], Node);
                tns.SetValue(treeListColumn1, dv1["NodeName"]);
                tns.Tag = dv1;
                GetCentralChild(dt, tns, Convert.ToInt16(dv1["KeyFieldName"]));
            }
        }  

 

DevExpress TreeList利用递归绑定数据,布布扣,bubuko.com

DevExpress TreeList利用递归绑定数据

标签:des   style   blog   color   数据   for   ar   div   

原文地址:http://www.cnblogs.com/huangzhenhua/p/3886451.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!