Generating Tree-like UI structures
In many of my projects I have had to generate non-binary trees using information from the database and then display them in a “tree-like” structure as shown below.
My algorithm is very simple and it makes use of Dan Vanderboom’s excellent Generic Tree Collection but frankly I’m not satisfied with certain aspects of my algorithm. The main issue – the data can never be retrieved in the same order as shown above from the database.
Now that we have a collection ready, we can generate the tree structure
Finally, I add the items to my drop-down control by calling
Let’s have a look at the function
I know I could have used LINQ but many of my projects are running in .NET 2.0 so I had to go old-school! I’m looking forward to your valuable comments as to how YOU would do this and why your solution is more efficient than mine.