Пример #1
0
        protected void BindChildTree(TreeNode node, string strMenu)
        {
            string  nodeid = node.Value;
            DataSet ds     = dal.GetMenuListByWhere(" a.[Parent] = '" + nodeid + "' ");

            foreach (DataRow row in ds.Tables[0].Rows)
            {
                Model.SYS.SYS_Menu model = DataConvert.DataRowToModel <Model.SYS.SYS_Menu>(row);
                string             name  = model.Name;
                string             id    = model.No;
                TreeNode           td    = new TreeNode(name, id);
                if (strMenu.Contains(id))
                {
                    td.Checked = true;
                }
                td.SelectAction = TreeNodeSelectAction.None;
                BindChildTree(td, strMenu);
                node.ChildNodes.Add(td);
            }
        }
Пример #2
0
        protected void BindTreeView(string strMenu)
        {
            tvModel.Nodes.Clear();
            DataSet ds = dal.GetMenuListByWhere(" a.[Parent] = '' ");

            foreach (DataRow row in ds.Tables[0].Rows)
            {
                Model.SYS.SYS_Menu model = DataConvert.DataRowToModel <Model.SYS.SYS_Menu>(row);
                string             name  = model.Name;
                string             id    = model.No;
                TreeNode           td    = new TreeNode(name, id);
                if (strMenu.Contains(id))
                {
                    td.Checked = true;
                }
                td.SelectAction = TreeNodeSelectAction.None;
                BindChildTree(td, strMenu);
                tvModel.Nodes.Add(td);
            }
            tvModel.ExpandAll();
        }