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>
原文:http://www.cnblogs.com/adolphyang/p/5106590.html