Recursive TreeView in ASP.NET

Posted by waqasahmed on Stack Overflow See other posts from Stack Overflow or by waqasahmed
Published on 2010-04-03T21:22:22Z Indexed on 2010/04/03 23:13 UTC
Read the original article Hit count: 474

Filed under:
|
|
|

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.

© Stack Overflow or respective owner

Related posts about recursion

Related posts about treeview