Hide Treeview Root Node

H

hartbypass

Hello,

I have treeview control that I am populating with a XML file. The
structure is:

Treenode
Level 1
Item1
Item2
Item3
Level 2
Item1
Item2
Item3

I do not want Treenode (root node) to show up, only Level and Level 2
and their applicable items. This would not seem that it should be to
difficult, but I can not seem to find an answer to it.

Thanks,
Greg
 
J

John B

hartbypass said:
Hello,

I have treeview control that I am populating with a XML file. The
structure is:

Treenode
Level 1
Item1
Item2
Item3
Level 2
Item1
Item2
Item3

I do not want Treenode (root node) to show up, only Level and Level 2
and their applicable items. This would not seem that it should be to
difficult, but I can not seem to find an answer to it.

Thanks,
Greg
How are you binding your xml to the treeview?

JB
 
H

hartbypass

Like this:

<asp:TreeView ID="TreeView1" runat="server"
DataSourceID="XMLSalesDataSource" ExpandDepth="1" ShowLines="True"
EnableTheming="True" EnableViewState="False"
OnSelectedNodeChanged="TreeView1_SelectedNodeChanged">
<DataBindings>
<asp:TreeNodeBinding DataMember="TREENODES"
TextField="text" />

<asp:TreeNodeBinding DataMember="treenode"
TextField="text" />
<asp:TreeNodeBinding DataMember="treenode1"
NavigateUrlField="NavigateURL" TextField="text"
ImageUrlField="imageURL" />
</DataBindings>
</asp:TreeView>
<asp:XmlDataSource ID="XMLSalesDataSource" runat="server"
DataFile="~/Documents/Sales/Filename.xml">
</asp:XmlDataSource>


TREENODES
treenode
treenode1
treenode1
treenode1
treenode
treenode1
treenode1
treenode1

The treenode1 is a link to a file, like a word doc, I am also having an
issue trying to launch to a target="_blank". I tried using the Target
property of the treeview control, but my guess is that means something
else. I had it working in 1.1 with the treeview there, but had to do a
lot more coding and I am trying to convert everything to 2.0.

Thanks.
 
H

hartbypass

Ignore the bottom part of the response I got the target to work. I
must have been using the wrong value from my xml file or something.

Thanks,
Greg
 
J

John B

hartbypass said:
Like this:

<asp:TreeView ID="TreeView1" runat="server"
DataSourceID="XMLSalesDataSource" ExpandDepth="1" ShowLines="True"
EnableTheming="True" EnableViewState="False"
OnSelectedNodeChanged="TreeView1_SelectedNodeChanged">
<DataBindings>
<asp:TreeNodeBinding DataMember="TREENODES"
TextField="text" />

<asp:TreeNodeBinding DataMember="treenode"
TextField="text" />
<asp:TreeNodeBinding DataMember="treenode1"
NavigateUrlField="NavigateURL" TextField="text"
ImageUrlField="imageURL" />
</DataBindings>
</asp:TreeView>
<asp:XmlDataSource ID="XMLSalesDataSource" runat="server"
DataFile="~/Documents/Sales/Filename.xml">
</asp:XmlDataSource>


TREENODES
treenode
treenode1
treenode1
treenode1
treenode
treenode1
treenode1
treenode1

The treenode1 is a link to a file, like a word doc, I am also having an
issue trying to launch to a target="_blank". I tried using the Target
property of the treeview control, but my guess is that means something
else. I had it working in 1.1 with the treeview there, but had to do a
lot more coding and I am trying to convert everything to 2.0.

<...>
I cant see any other solution other than editing the xml before binding
if you want to hide the root node :(

Sorry

JB
 

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