Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hi,

I am showing record in treeview format using asp .net treeview control.

Note: + and - is treenode expand event and tree1,tree1.1,tree2,tree2.1,tree2.2 are treenode change event. this we know generally.

for example:
+ tree1
     - tree1.1
     -tree1.2
+ tree2
      -tree2.1
      -tree2.2


so, i took my data from data base and formed in treeview format. till now everything works fine.

the problem is that: when i click + on tree1 family , it expands it's child---> here also no issue.

and secondly when i click + on tree2 family , it expands it's child----> here the first family (ie tree1) should collapse automatically. right? but it is not doing. that is the issue.

Note: here when you click + and - , no loading or postpack. just expand.

so, i used one coding follows which solves that problem. but it is loading or does post pack. so, it faces slow just expand and collapse.


bool Block = false;
protected void tree_expand(object sender, TreeNodeEventArgs e)
{

if (Block == true) // stop recursive re-entrancy
return;
Block = true;

treeview1.CollapseAll();                               // treeview1 is nothinbut. it is id of treeview in aspx page. <asp:treeview id="treeview1".......

TreeNode Node = e.Node;
while (Node != null)
{
Node.Expand();
 Node = Node.Parent;

Node = Node.Parent;
}


Block = false;
}


please help me out..lead me in right way. thank you. somebody says use jquery plugin with json. but i am not able find exact coding or step by step to do that. so, i have done normal asp.net treeview. if you solve atleast the problem , it will be more helpful.
Posted
Updated 13-Aug-13 2:54am
v3
Comments
BillWoodruff 14-Aug-13 19:37pm    
The behavior you describe sounds like the way MS Trees are meant to work. Expanding or contracting a root, or sibling node does not affect other root, or sibling nodes.

Are you saying that when you expand node 1 with two children which is a root node, and then you go expand node 2 which is a root node with two chidren: that node 1 should now automatically collapse ? Yes, you can make that happen in code if you wish.

To help you with this, you need to specify exactly the behavior you wish to see, under the exact conditions you wish to see it.

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