Hello,
** I have created a class to build and return a treeview.
** On my web page, I have created a 'treeview control' and I want to populate this treeview control from the class that returns the treeview.
** When I debug the application, I see that the class is building the tree perfectly with the nodes and all. The debug watch window shows that the treeview control in the page also gets the data from this 'treeview' returned by the class correctly.
** The problem is the 'TREEVIEW CONTROL' is not displaying anything on the page itself.
eg:
CLASS RETURNING TREEVIEW:
namespace mytree
{
public class buildtree
{
public treeview fill_my_tree()
{
logic written here to fill the tree;
return(mytreeview);
}
}
}
IN MY WEBPAGE:
buildtree tree1= new buildtree();
treeview1 = tree1.fill_my_tree();
PROBLEM: treeview1 in debug mode shows the nodes in the watch window. But, nothing is displayed on the user screen.
Can someone help me? Thanks for your help and time.
FYI: I am developing in c#, VS 2008.
Thanks..
Populating treeview from a class returning treeview
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Amit ChoudharyRank #145 · 15.8K reputationPosted Feb 26, 2010, 1:13 AM EST
Try this,
buildtree tree1=tree1.fill_my_tree();
this.Form.Controls.add(tree1);
Don't forget to mark as answer if it helps you.
pvathy3 reputationPosted Feb 26, 2010, 4:19 AM EST