Recursive TreeView in ASP.NET
- by waqasahmed
I have an object of type list from which I wish to use to populate a treeview in asp.net c#.
Each object item has:
id | Name | ParentId
so for example:
id | Name | ParentId
-------------------------
1 | Alice | 0
2 | Bob | 1
3 | Charlie | 1
4 | David | 2
In the above example, the parent would be Alice having two children Bob and Charlie. David is the child of Bob.
I have had many problems trying to dynamically populate the treeview recursively in c# ASP.NET
Does any one have a simple solution?
Btw: you can use People.Id, People.Name and People.ParentId to access the members since it is an object belonging to list.
I can post you my code so far (many attempts made) but not sure how useful it will be.