ratkinso666
asked on
Start Treeview collapsed
Hi all, I have a hopefully simple one, when I start my page it starts with my treeview fully expanded. I want it to start at 1 level down. I have tried loading into my
page_load
TreeView1.Nodes(1).Collaps eAll
and I tried
TreeView1.Nodes(1).Expande d = False
I tried changing various variables in properties, but no help...
This is loaded in the MasterPage and uses a SiteMapDataSource with a web.sitemap...
Thanks,
Randy
page_load
TreeView1.Nodes(1).Collaps
and I tried
TreeView1.Nodes(1).Expande
I tried changing various variables in properties, but no help...
This is loaded in the MasterPage and uses a SiteMapDataSource with a web.sitemap...
Thanks,
Randy
ASKER
It does not seem to make a difference...
But I did notice that the Treeview1.Nodes count is 0
But I did notice that the Treeview1.Nodes count is 0
Ok, you're doing this too early.
You must do it after the databinding is done. Do it in Page_PreRender instead.
You must do it after the databinding is done. Do it in Page_PreRender instead.
ASKER
Here is a section of my Web.sitemap, perhaps I am not entering the different nodes correctly...
<siteMapNode url="http://web1/" title="Home" description="">
<siteMapNode url="Accounting\AccountingHome.aspx" title="Accounting" description="">
<siteMapNode url="PaymentStatus\AP_PaymentStatus.aspx" title="AP Payment Status" description="">
</siteMapNode>
<siteMapNode url="http://web1/HydroChemWebsite/Accounting/SupplierContactList.xls" title="Supplier Contact List" description="">
</siteMapNode>
</siteMapNode>
<siteMapNode url="AllianceGroup\AllianceGroupHome.aspx" title="Alliance Group" description="">
<siteMapNode url="http://AllianceContacts.asp?Section=Alliance" title="Contacts" description="">
</siteMapNode>
<siteMapNode url="http://Reports/Report_CustomerOT.aspx" title="Customer OT Rpt" description="">
</siteMapNode>
</siteMapNode>
</siteMapNode>
ASKER
I changed it to there and get the same result. In the
For Each node In TreeView1.Nodes
there are 0 nodes at that point, so it just skips right on by that and its inner loop..
For Each node In TreeView1.Nodes
there are 0 nodes at that point, so it just skips right on by that and its inner loop..
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Thanks, that one worked. I could have sworn I had already tried that one, but I have been messing with several of them, so I probably changed it and then tested it in a different one than the one I had changed it in.
Thanks for the great help!!
Thanks for the great help!!
ASKER
thanks again for the great help, it is appreciated
Dim node, node2 As TreeNode
For Each node In Treeview1.Nodes
For Each node2 In node.ChildNodes
node2.CollapseAll()
Next
Next
If you just want the first level you do:
Treeview1.CollapseAll()