首页 > Web开发 > 详细

WebForm中创建树节点TreeNode

时间:2016-01-06 20:16:19      阅读:358      评论:0      收藏:0      [点我收藏+]

Tree:

 

namespace ECTECH.NorthSJ.Web.SysData
{
    public partial class testTree : BasePage
    {
        protected int roleId = 5;

        protected void Page_Load(object sender, EventArgs e)
        {
            if(!IsPostBack)
            {
            List<Model.Funcs> list = new BLL.RoleFuncs().GetRFunc("0", roleId);
            foreach(Model.Funcs func in list)
            {
                FineUI.TreeNode node = new TreeNode() { Text = func.Name, NodeID = func.ID.ToString(), Leaf = false, EnableCheckBox=true };
                LoadChildNode(func.FuncCode,roleId, node);
                tree1.Nodes.Add(node);
            }
            }
        }

        private void LoadChildNode(string parentCode, int roleId,TreeNode node)
        {
            List<Model.Funcs> list = new BLL.RoleFuncs().GetRFunc(parentCode, roleId);
            foreach (Model.Funcs func in list)
            {
                TreeNode nodeChild = new TreeNode() { Text = func.Name, NodeID = func.ID.ToString(), Leaf = true, EnableCheckBox = true };
                node.Nodes.Add(nodeChild);
            }
        }

        protected void btn1_Click(object sender, EventArgs e)
        {
            string[] ids = tree1.SelectedNodeIDArray;
            string idStr = string.Join(",", ids);
            lbResult.Text = idStr;
        }

    }

 

 

Form:

    <form id="form1" runat="server">
    <div>
    <x:PageManager ID="PageManager1" AutoSizePanelID="RegionPanel1" runat="server">
    </x:PageManager>
    <x:Tree ID="tree1" EnableMultiSelect="true"  runat="server"></x:Tree>
    <x:Button ID="btn1" Text="确定"  runat="server" OnClick="btn1_Click"></x:Button>
    <x:Label ID="lbResult" EncodeText="false" runat="server"></x:Label>
    </div>
    </form>

 

WebForm中创建树节点TreeNode

原文:http://www.cnblogs.com/adolphyang/p/5106590.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!