在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls;
using Qhr.QhrService;
namespace Qhr { public partial class test : System.Web.UI.Page { Qhr.QhrService.QhrServiceClient proxy = new QhrService.QhrServiceClient(); QhrService.MyProtocolStructureCollection collection = null;
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { collection = proxy.GetAllProtocolStructure(); LoadTree(); } }
private void LoadTree() { this.TreeView1.Nodes.Clear(); InitTree(this.TreeView1.Nodes, null); }
private void InitTree(TreeNodeCollection Nds, string parentId) { TreeNode tmpNd = null; MyProtocolStructureCollection collectionTemp = new MyProtocolStructureCollection(); foreach (MyProtocolStructure psTemp in collection) { if (psTemp.Pid == parentId) { collectionTemp.Add(psTemp); } }
foreach (MyProtocolStructure ps in collectionTemp) { tmpNd = new TreeNode(); tmpNd.Text = ps.Name; tmpNd.Value = ps.Id; if (parentId == null) { tmpNd.Expanded = true; } else { tmpNd.Expanded = false; } Nds.Add(tmpNd); InitTree(Nds[Nds.Count - 1].ChildNodes, ps.Id); } } } }
|
请发表评论