Get All TreeList Items

3 posts, 0 answers
  1. William
    William  avatar
    72 posts
    Member since:
    Jun 2011

    Posted 16 Dec 2011 Link to this post

    I would like to iterate through all of my TreeList items, but I can only seem to return the parent items and not the children. 

    Here is the code I have so far:

    foreach (TreeListDataItem i in notificationsTree.Items)
    {
        string test21 = i.Cells[3].Text.ToString();
    }
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 19 Dec 2011 Link to this post

    Hello,

    Take a look into the following code snippet.
    Accessing Cells and Items

    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Abhishek
    Abhishek avatar
    45 posts
    Member since:
    Jul 2012

    Posted 18 Jan 2012 Link to this post

    Hello William,

    I have posted one example for your issue, In which i am iterating through the expanded nodes so that you can get the child node item text. I don't know it's correct way or not.
    Note: To iterate through the child nodes parent node should be expanded. I wrote for node expansion and commented that code please have look.
    foreach (TreeListDataItem item in rtlBusinessUnit.Items)
               {
                   if (item.CanExpand)
                   {
                       if (item.Expanded)
                       {
                           if (item.ChildItems.Count > 0)
                           {
                               foreach (TreeListDataItem Child in item.ChildItems)
                               {
                                   string ItemName = Child["Name"].Text;
                               }
                           }
                       }
                       //else
                       //{
                       //    item.Expanded = true;
                       //    if (item.ChildItems.Count > 0)
                       //    {
                       //        foreach (TreeListDataItem Child in item.ChildItems)
                       //        {
                       //            string ItemName = Child["Name"].Text;
                       //        }
                       //    }
                       //    //item.Expanded = false;
                       //}
                   }             


    Thanks,
    Abhishek K
Back to Top