Hi,
sureshkumar.veesam: Now If I select any node , then I'm displaying that node using label control. Now I have to Add and Delete nodes to the treeview control using Add and Delete Buttons.
1. If you want to display the selectednode in the label control, you can write some in the SelectedNodeChanged event, like below:
protected void TreeView1_SelectedNodeChanged(object sender, EventArgs e)
{
this.lbl.Text = this.TreeView1.SelectedNode.Text;
}
2. If you want to add the node, you can do like below:
protected void Button1_Click(object sender, EventArgs e)
{
TreeNode tn = new TreeNode("New Node", "New", "defaut.aspx");
//this.TreeView1.Nodes.Add(tn);// add the node at the rootnode
//add the node in some treenode.===========
TreeNode parentNode = (TreeNode)this.TreeView1.FindNode("Home");
parentNode.ChildNodes.Add(tn);
====================================
}
3. If you want to deleted the nodes, you can use the remove method, like below:
protected void Button1_Click(object sender, EventArgs e)
{
TreeNode tn = (TreeNode)this.TreeView1.FindNode("Home");
this.TreeView1.Nodes.Remove(tn);
}
Hope it helps.
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Yours sincerely,
Amanda Wang
Microsoft Online Community Support