protected void CustomTreeView1_SelectedNodeChanged(object sender, EventArgs e) { // 获取保存在树节点钟的对象. if (CustomTreeView1.SelectedNode != null) { CustomTreeNode treeNode = (CustomTreeNode)CustomTreeView1.SelectedNode; MyItem item = (MyItem)treeNode.Tag; lbMessage.Text = string.Format("选择的对象是: {0}", item.Title); } }
protected void CustomTreeView1_SelectedNodeChanged(object sender, EventArgs e) { // Retrieve the object which is stored in the tree node. if (CustomTreeView1.SelectedNode != null) { CustomTreeNode treeNode = (CustomTreeNode)CustomTreeView1.SelectedNode; MyItem item = (MyItem)treeNode.Tag; lbMessage.Text = string.Format("The selected object is: {0}", item.Title); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { // 在TreeView 控件中显示10个树节点. for (int i = 0; i < 10; i++) { CustomTreeNode treeNode = new CustomTreeNode(); // 关联自定义对象到树节点. MyItem item = new MyItem(); item.Title = "对象 " + i.ToString(); treeNode.Tag = item; treeNode.Value = i.ToString(); treeNode.Text = "节点 " + i.ToString(); CustomTreeView1.Nodes.Add(treeNode); } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { // Display 10 nodes in the TreeView control. for (int i = 0; i < 10; i++) { CustomTreeNode treeNode = new CustomTreeNode(); // Assign a custom object to the tree node. MyItem item = new MyItem(); item.Title = "Object " + i.ToString(); treeNode.Tag = item; treeNode.Value = i.ToString(); treeNode.Text = "Node " + i.ToString(); CustomTreeView1.Nodes.Add(treeNode); } } }