using TreeView-control ???

C

Chris

Hi,

anyone experience with the TreeView control that is available in the
Microsoft.Web.UI.WebControls component ?

I want to add a few nodes to the TreeView-control but don't know quite how :

// Creating a few nodes
TreeNode node1 = new TreeNode();
node1.Text = "Canada";
TreeNode node2 = new TreeNode();
node2.Text = "Spain";

// Adding to the collection
TreeNodeCollection coll = new TreeNodeCollection();
coll.Add(node1);
coll.Add(node2);

// View nodes in the TreeView-control
TreeView vw = new TreeView();
vw.<WHAT METHOD DO I USE NOW IN ORDER TO ADD THE NODES TO
THE VIEW ?? >

Note : I don't want to use the TreeNodeSrc-property which takes data out of
an
XML-file, no I need to add the data programatically

Thanks
Chris
 
S

Scott Allen

Hi Chirs:

In your code vw.Nodes would be the top level tree node collection to
add to.

vw.Nodes.Add(node1);

Note you'll also need to get your TreeView onto the web form. The
easiest way is to add it to the ASPX file in a runat="server" tag.

I have an of working programatically with a TreeView, although the
main thrust of the article is Reporting Services integration:

http://odetocode.com/Articles/95.aspx
 
C

Chris

thanks Scott !

Chris

Scott Allen said:
Hi Chirs:

In your code vw.Nodes would be the top level tree node collection to
add to.

vw.Nodes.Add(node1);

Note you'll also need to get your TreeView onto the web form. The
easiest way is to add it to the ASPX file in a runat="server" tag.

I have an of working programatically with a TreeView, although the
main thrust of the article is Reporting Services integration:

http://odetocode.com/Articles/95.aspx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top