views:

1172

answers:

2

Does anyone know how to show a asp:TreeView always expanded to the leaves? So if I have a 2-level tree, I want it to be expanded at all times. Is there a property on TreeView that does this or could you show the code snippet on how to do this?

Thank you very much! Ray.

+1  A: 

aspx.cs:

protected void Page_Load(object sender, EventArgs e)
{
 TreeView1.ExpandAll();
}

if you also want to disable expand-collapse symbols in the tree:

<asp:TreeView ID="TreeView1" runat="server" ShowExpandCollapse="false">
</asp:TreeView>
maxnk
A: 

And you can use an Integer if you only want to show the roots item per defualt:

    protected void Page_Load(object sender, EventArgs e)
    {
        TreeView1.ExpandDepth = 1;
    }
C Stahl