Normal
Maybe I'm overlooking something here but to me this sounds like what you're searching for is recursion...Let me try if I can write some pseudo code:[CODE]public void Main(){//entry point TreeNode rootNode = new TreeNode("I am root"); GetSubNodes(0, rootNode);}public void GetSubNodes(int _id, TreeNode _node){ List<Category> subCategories = GET_SUB_FROM_SQL(_id);//get the sub-categories from sql foreach(Category c in subCategories) { TreeNode node = new TreeNode(c.category_name); node.Tag = c; GetSubNodes(c.category_id, node);//this is the recursion _node.SubNodes.Add(c); }}[/CODE]Fyi it's already late and I'm sure there's something wrong with the code but it should give you the idea
Maybe I'm overlooking something here but to me this sounds like what you're searching for is recursion...
Let me try if I can write some pseudo code:
[CODE]
public void Main()
{//entry point
TreeNode rootNode = new TreeNode("I am root");
GetSubNodes(0, rootNode);
}
public void GetSubNodes(int _id, TreeNode _node)
{
List<Category> subCategories = GET_SUB_FROM_SQL(_id);//get the sub-categories from sql
foreach(Category c in subCategories)
TreeNode node = new TreeNode(c.category_name);
node.Tag = c;
GetSubNodes(c.category_id, node);//this is the recursion
_node.SubNodes.Add(c);
[/CODE]
Fyi it's already late and I'm sure there's something wrong with the code but it should give you the idea