How to retrieve data from the DB for recursively binding a jquery treeview using asp.net mvc
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 c开发者_C百科hild 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.
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.
精彩评论