TreeView with SiteMap and Collapse

Last post 07-04-2008 1:17 AM by Amanda Wang - MSFT. 3 replies.

Sort Posts:

  • TreeView with SiteMap and Collapse

    07-01-2008, 11:56 AM
    • Member
      27 point Member
    • mldesanctis
    • Member since 02-12-2008, 9:25 PM
    • Posts 127

    When I hardcode a TreeView's nodes, I have the option of making folders collapsed automatically.  Is there a way to do this while using a sitemap and tell folders to be collapsed by default when the page loads?

  • Re: TreeView with SiteMap and Collapse

    07-02-2008, 10:52 PM

    Hi,

    There is an ExpandDepth property in the ASP.Net TreeView Contro, its default value is FullyExpand.

    If you want the TreeView collapsed when the page load, you can set the TreeView's ExpandDepth  is 0.

    Hope it helps.

    Amanda Wang
    Microsoft Online Community Support

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
  • Re: TreeView with SiteMap and Collapse

    07-03-2008, 10:21 AM
    • Member
      27 point Member
    • mldesanctis
    • Member since 02-12-2008, 9:25 PM
    • Posts 127
    I see that option, but I want to pick and choose which folders are open by content, not by depth.
  • Re: TreeView with SiteMap and Collapse

    07-04-2008, 1:17 AM
    Answer

    Hi,

    mldesanctis:
    I see that option, but I want to pick and choose which folders are open by content, not by depth.

    The TreeNode has an Expand method, which can expand the TreeNode,

    for example:

     if (node.ChildNodes.Count != 0)
            {
                foreach (TreeNode tn in node.ChildNodes)
                {
                    if (tn.Text == strTitle)
                    {
                        tn.Expand();
                    }
                    else if (tn.ChildNodes.Count != 0)
                    {
                        foreach (TreeNode tnNode in tn.ChildNodes)
                        {
                            retriverNode(tnNode, strTitle);
                        }
                    }
                }
            }

    Hope it helps.

    Amanda Wang
    Microsoft Online Community Support

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Page 1 of 1 (4 items)