Building a Tree from DataTable results with the node structure formatted as \Node1\Node2\
Posted on 2008-06-24
I've been banging my head against a wall for the past few days with the problem of turning DataTable results into a Tree Structure to populate a TreeView control. The tree path is stored in a field called Path.
Normally I do a recursive query using parent ID's but this system is different as the Root Parents Childs are all stored in the string. I've been doing a For each Row in DataSet and breaking down each Path into a string array using NodeList = Path.Split(CChar("\")) but its the building of the nodes that I just cant get my head around.
Idealy I dont want to requery the database again, the results in the datatable from a stored procedure with a fair few params. So I'd have to work with data just in the datatable.