ASP.NET TreeView automatically expands?

Does anyone know how to show asp: TreeView always expands to leaves? So if I have a two-tier tree, I want it to expand constantly. Is there a TreeView property that does this, or can you show a piece of code on how to do this?

Many thanks! Ray.

+1


source to share


2 answers


aspx.cs:

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

      



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

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

      

+2


source


And you can use Integer if you only want to show the root element in defualt:



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

      

0


source







All Articles