I'm looking to populate a treelist with our company structure. In my database i have a table with positions that have the following layout
PositionID - Integer for the position
PositionText - Text for the position
ReportsToID - Position ID that this position reports to.
I would like to load the positions that first report to positionID=0 (Root level) and then cascade load each of the positions from there onwards while populating a Treeview so i can then have somthing like:
-Position 1
-Position 3
-position 5
-Position 7
-Position 4
-Position 2
Any suggestions on how to achieve this would be great, even some sudocode would help me on the right track.
EDIT: I am able comfortable with adding nodes to my tree view, but where i am getting a little hung up is how to loop/recursive search so that i can work through my items and add everything. Im thinking somehow i need to add my first node, see if anyone reports to that node. If there are, add them. Then for the next level nodes, see if anyone reports to them and then continue. I'm probably a little stuck on how to do the loop cleanly and efficiently.