get all items in RadTreeList include collapse items

4 posts, 0 answers
  1. Joehom
    Joehom avatar
    2 posts
    Member since:
    Mar 2012

    Posted 16 Apr 2013 Link to this post

    ask I know for RadTreeList1.Items is only can get currently visible items, which mean those collapse item will not get into the list. Can I know any API that can get all items in RadTreeList include collapse item.
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 17 Apr 2013 Link to this post


    Try the following.
    protected void Button2_Click(object sender, EventArgs e)
      foreach (TreeListDataItem parentitem in RadTreeList1.Items)
        if (parentitem.ChildItems.Count > 0)
             foreach (TreeListDataItem Child in parentitem.ChildItems)
                  string ItemName = Child["UniqueName"].Text;

  3. Victor
    Victor avatar
    1 posts
    Member since:
    Jun 2013

    Posted 06 Jun 2013 Link to this post

    this is not working.
  4. Angel Petrov
    Angel Petrov avatar
    1075 posts

    Posted 11 Jun 2013 Link to this post

    Hi Victor,

    In order to traverse all the items in the RadTreeList you will need to use recursion as demonstrated in the code snippet below:

    protected void Unnamed_Click(object sender, EventArgs e)
            foreach (TreeListDataItem treeListItem in RadTreeList2.Items)
        public void TraverseAllItems(TreeListDataItem treeListItem)
            if (treeListItem.ChildItems.Count > 0)
                foreach (TreeListDataItem childItem in treeListItem.ChildItems)

    Please note that when a TreeListDataItem is collapsed but has child records it's ChildItems.Count value will be equal to zero until it is expanded.

    Angel Petrov
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Back to Top