views:

45

answers:

1

I have a table structure like this.

id | Name | ParentId so for example:

id | Name | ParentId

1 | Alice | 0 2 | Bob | 0 3 | Charlie | 1 4 | David | 2

where 'Alice' and 'Bob' are Parent nodes( which has Id = 0) and Alice has a child node named 'Charlie' and 'Bob' has a child node named 'David'. My question is, I need to retrieve the parent separately and the children in a collection. The 'Children' collection can have multiple parents and its children. Can anyone send me a code snippet using which I can retrieve Data from the database and populate the tree.

+1  A: 

Similar to How to populate treeview except the classes used will be from the System.Web.UI.WebControls namespace (they are named the same).

Also BeginUpdate and EndUpdate methods don't exist for obvious reasons.

Jaroslav Jandek
It is usually not a good idea to use server controls in a asp.net mvc application. And this task is (at least in my opinion) a lot easier without server controls.
Mattias Jakobsson