This is a migrated thread and some comments may be shown as answers.

[Solved] Using LINQ to search nodes?

1 Answer 233 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Josh Anderson
Top achievements
Rank 1
Josh Anderson asked on 08 Jan 2009, 08:15 PM
Has anyone successfully employed LINQ to search the Nodes collection for a substring in the node's text value?  I have a need to allow site visitors to search the node list without necessarily needing to know the full text of the node.

For example, if I have "Bob's Pizza" buried in the hierarchy, I'd like them to be able to search for "pizza" and select that node.  My thought was to use LINQ to query the collection for matches then allow the person to go from match to match.

Has anyone done this before?  Is it possible?

Josh

1 Answer, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 09 Jan 2009, 09:01 AM
Hi Josh Anderson,

You can use LINQ to query RadTreeView like this:

var nodes = from node in RadTreeView1.GetAllNodes()
                  where node.Text.EndsWith("1")
                  select node;

        foreach (RadTreeNode node in nodes)
        {
            Response.Write("Matching nodes:" + node.Text);
        }

Regards,
Albert
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
TreeView
Asked by
Josh Anderson
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Share this question
or