views:

192

answers:

0

Hey There. Sorry if this is more obvious to most than it is to me but ... I would be most appreciative of some help.

I have a treeview bound to a sitemap. Everything works just fine - so it seems to be set up well. However, I cannot access the nodes in the treeview. Here is the minimum code to demonstrate:

.aspx:

<form id="form1" runat="server">
<div>
<asp:SiteMapDataSource ID="Navigation" runat="server" />
<asp:Label runat="server" ID="CurrNodeVal" EnableViewState="false"></asp:Label>
<asp:TreeView ID="TreeView" runat="server" DataSourceID="Navigation" />
</div>
</form>

.aspx.cs:

protected void Page_Load(object sender, EventArgs e) 
{
string siteMapProvider = "JuniorOfficerMap"; 
Navigation.SiteMapProvider = siteMapProvider;
CurrNodeVal.Text = (TreeView.Nodes == null) ? "TreeView.Nodes is NULL " : "TreeView Found! ";
CurrNodeVal.Text += "There are " + TreeView.Nodes.Count + " nodes in the tree view. ";

}

When I load the page, the treeview is shown correctly (with 6 nodes - just as laid out in the XML file), but I cannot access thenodes in the treeview. See below:

-- TreeView Found! There are 0 nodes in the tree view.

Yahoo
Page 5
Page 6
Page 1
Page 3
Page 4
Page 2

So - how do I access the nodes in order to set their attributes? This can't be difficult - so I know I am missing some fundamental issue here. Can someone correct my wayward thought process?

Thanks so much!

Murray