Databinding Treeview and Search

5 posts, 1 answers
  1. kris860911
    kris860911 avatar
    8 posts
    Member since:
    Jun 2007

    Posted 27 Mar 2008 Link to this post

    I am binding a treeview to a datatable.
    The treeview has self-referencing data. And it loads correctly and shows correctly.

    The problem I am having is this. Once the data is reloaded, I want to select the node that was selected already. So I need to use the Find method and make the node selected,

    However, I read that the Find Method uses the Name Property to match the search term, but it seems like the Name Property is not populated when bound to a datasource.

    Do you suggest a way to overcome this problem?

  2. Answer
    Nikolay avatar
    1805 posts

    Posted 28 Mar 2008 Link to this post

    Hi kris860911,

    You can search by two different RadTreeView properties when you bind to a DataSource. The first one is the Text property, which is popluated as a DisplayMember and the second one is the Tag property which is populated as a ValueMember.

    Currently, RadTreeView does not implement the FindNodeByText method, so please refer to the implementation below:

    RadTreeNode FindNodeByText(RadTreeNodeCollection nodeCollection, string text)  
         foreach (RadTreeNode node in nodeCollection)  
             if ((node.Text == text) && (node != this.radTreeView1.SelectedNode))  
                 return node;  
             RadTreeNode result = this.FindNodeByText(node.Nodes, text);  
             if (result != null)  
                 return result;  
         return null;  

    I hope this helps. If you have additional questions, do not hesitate to contact me.

    Best wishes,
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
    TECH GURU avatar
    1 posts
    Member since:
    Aug 2009

    Posted 16 Sep 2009 Link to this post

    I found this after I posted my query. I have a question regarding the databinding implementation. Any reason why the ValueMember was copied to the Node.Tag property instead of the Node.Name property? Doing this would have eliminated the need to write a custom find method and use the Nodes.Find() method instead.

    - TG
  4. Victor
    Victor avatar
    1358 posts

    Posted 17 Sep 2009 Link to this post


    Please refer to your first ticket about the same.

    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  5. Stefan
    Stefan avatar
    2911 posts

    Posted 23 Mar 2011 Link to this post


    Please note that in Q1 2011 we have introduced a major upgrade of RadTreeView control, which is now virtualized and fully customizable. Feel free to download the latest release and try it out. For more information on our latest release refer to this blog post.

    Best wishes,
    the Telerik team
Back to Top