Populate treeview from datatable recursively

Hi, I have a datatable like the following example:

ID       Parent_ID       Category_Name
---      ------------       -------------------
1         NULL                xyz
2         1                       sub_xyz
3         1                       sub_xyz
4          2                      sub_aaa

How can I populate it recursively(and dynamically)?

I found many code samples on the internet but it was for the .NET version 1, it does not work for version 3.5
LVL 3
Abdu_AllahAsked:
Who is Participating?
 
Ammar GaffarSoftware EngineerCommented:
Hi Abdu_Allah,

There are a lot of solutions writen in Expert-Exchange for simiular to your issue,
Please check bellow solution, it may help you:

http://www.experts-exchange.com/Programming/Languages/.NET/Q_21624762.html?sfQueryTermInfo=1+build+databas+from+treeview+vb.net

Good Luck
0
 
Abdu_AllahAuthor Commented:
There is no recursion in that solution!
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
Ammar GaffarSoftware EngineerCommented:
Dear Abdu Allah,
Did you read Mr.MxTxL comment (The Accepted solution)? it is same as your issue!
His code example includes three fields (StructureID,Name and ParentID) and yours is ID,Parent_ID,Category_Name!

Please be patient and read the whole Mr.MxTxL comment.

Good Luck
0
 
Abdu_AllahAuthor Commented:
Nested loop is  not a good way to do it, it will kill the performance.
0
 
Ammar GaffarSoftware EngineerCommented:
Hi Abdu_Allah,
Regardless of your solution acceptance, recursion is a subject. How to apply it is a technical issue.
Depends on m
You commented on nested loop, although the accepted solution has Nested loop!

Anyhow, good luck.
0
All Courses

From novice to tech pro — start learning today.