Guest User

generate treeview nodes programmatically

a guest
Feb 27th, 2012
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. node id parent node id
  2.  
  3. ------- --------------
  4.  
  5. 100 null //this is the root node
  6.  
  7. 101 100
  8.  
  9. 123 101
  10.  
  11. 124 101
  12.  
  13. 126 101
  14.  
  15. 103 100
  16.  
  17. 104 100
  18.  
  19. 109 100
  20.  
  21. 128 109
  22.  
  23. 122 100
  24.  
  25. 127 122
  26.  
  27. 129 127
  28.  
  29. 130 129
  30.  
  31. AddChildNodes(TreeNode parentNode)
  32. {
  33. var childNodeIds GetChildNodeIds(parentNode.Id);
  34. foreach (int childNodeId in childNodeIds)
  35. {
  36. TreeNode childNode = new TreeNode();
  37. //set other properties...
  38.  
  39. //add to parent
  40. parentNode.Nodes.Add(childNode);
  41.  
  42. //call same function recursively
  43. AddChildNodes(childNode);
  44. }
Add Comment
Please, Sign In to add comment