Click here to Skip to main content
15,896,430 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I need to set the treeview1.selectednode.childnodes as parent each time the user makes a click on it, but on event click I am making a post back to open the right node so in the following code i need to make that in every postback redraws the treeview but dismiss the parent and set child as parent...


C#
if (IsPostBack == true)
{
  TreeView1.RootNodeStyle.CssClass = "HideParent";
  TreeNode tn = TreeView1.FindNode(navigate);
  TreeView1.Nodes[0].ChildNodes.Remove(tn);
  TreeView1.DataBindings.Clear();
  //BindTreeView(0);
}
Posted
Updated 2-Nov-12 3:17am
v2

1 solution

TreeNode node_value = TreeView1.SelectedNode;

if(!IsPostBack == true){
TreeView1.Nodes.Clear();
TreeView1.Nodes.Add(node_value);
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900