首页 > 代码库 > Web TreeView 加载级联数据

Web TreeView 加载级联数据

        protected void Page_Load(object sender, EventArgs e)        {            if (!IsPostBack)            {                dt = BLL.GetTable();                LoadLYRProperties(0, null);            }        }        private DataTable dt = null;        public void Load(int FID, TreeNode pNode)        {            DataView dvTree = new DataView(dt);            //过滤ParentID,得到当前的所有子节点            dvTree.RowFilter = "[FID] = " + FID;            foreach (DataRowView Row in dvTree)            {                TreeNode root = new TreeNode();                if (pNode == null)                {                       root.Text = Row["NAME"].ToString();                    tvLyrProperties.Nodes.Add(root);                    root.Expanded = true;                    root.Value = Row["ID"].ToString();                    LoadLYRProperties(Int32.Parse(Row["ID"].ToString()), root);    //递归                }                else                {   //添加当前节点的子节点                    TreeNode subroot = new TreeNode();                    subroot.Text = Row["NAME"].ToString();                    pNode.ChildNodes.Add(subroot);                    subroot.Expanded = true;                    subroot.Value = Row["ID"].ToString();                    LoadLYRProperties(Int32.Parse(Row["ID"].ToString()), subroot);                    }            }        }

 

Web TreeView 加载级联数据