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

Nodes.Add and Databinding

2 Answers 66 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Bruce St.Clair
Top achievements
Rank 2
Bruce St.Clair asked on 25 Aug 2008, 07:13 PM

What I am trying to do is using code behind add a root1 called "All Providers" then databind another datatable to make them childs of root1.

Code snippet:

RadTreeNode root1 = new RadTreeNode("All Providers");

RadTreeView1.Nodes.Add(root1);

RadTreeView1.AppendDataBoundItems =

true;

RadTreeView1.DataBind();

But what happens they al become roots in thier own right and do not appear as childs to root1.  I know there must be a way but cant find out how with the help file. 

Thanks for any help.

2 Answers, 1 is accepted

Sort by
0
Bruce St.Clair
Top achievements
Rank 2
answered on 26 Aug 2008, 06:52 PM
Ok I finally figured it out.  Had to go at it from a different approach.  I changed my data fetch statement to include fake parent and child ID's.  Then databind it.  Here is the code incase anybody else runs into this problem.



Code Snippet:

-- Get the data         
          DataSet dsp = new DataSet();
           DB.m_da.SetRead("SELECT 'All Providers' AS [Name], '0' AS [ID], null as tree union SELECT [FName] + ' ' + [LName] AS [Name], [ID],0 as [Tree] FROM Provider WHERE [Inactive] = 0 ORDER BY 1", 1);
            DB.m_da.Run(ref dsp);

-- Bind the data to the RadTree
            RadTreeView1.DataSource = dsp;

            RadTreeView1.DataFieldID = "ID";
            RadTreeView1.DataTextField = "Name";
            RadTreeView1.DataFieldParentID = "Tree";
            RadTreeView1.DataBind();

0
Accepted
Veselin Vasilev
Telerik team
answered on 27 Aug 2008, 12:18 PM
Hello Bruce St.Clair,

Thank you for sharing the approach with the other community members.

Sincerely yours,
Veskoni
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
TreeView
Asked by
Bruce St.Clair
Top achievements
Rank 2
Answers by
Bruce St.Clair
Top achievements
Rank 2
Veselin Vasilev
Telerik team
Share this question
or