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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
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
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Abdu_AllahAuthor Commented:
Nested loop is  not a good way to do it, it will kill the performance.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.