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

RadTreeView LinqDatasource binding not working

3 Answers 68 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Axel
Top achievements
Rank 2
Axel asked on 26 Jan 2010, 06:58 PM
My code as I see it is exactly the same as the demo explaining this (I think).
Hope someone can find out why mt Radtree is not displaying any data.

This is my code:

    <telerik:RadTreeView ID="RadTreeView1" runat="server" Width="100%" Height="250px" 
          DataFieldID="code" DataFieldParentID="parentcode" 
        DataTextField="absencereasonname" DataValueField="code"   
        DataSourceID="LinqDataSource1">  
        <DataBindings> 
            <telerik:RadTreeNodeBinding Depth="0" Expanded="true" /> 
        </DataBindings> 
    </telerik:RadTreeView> 
    <asp:LinqDataSource ID="LinqDataSource1" runat="server"    
        ContextTypeName="Orbit.Benjamin.DB.PartyDataContext"   
        TableName="AbsenceReasons"   
        Select="new (code, absencereasonname, parentcode)">  
    </asp:LinqDataSource> 
 

and this is my DB table structure

    [code] [nvarchar](10) NOT NULL,  
    [absencereasonname] [nvarchar](100) NULL,  
    [parentcode] [nvarchar](10) NULL, 

I am calling DataBind() on PageLoad but my tree returns with 0 nodes.
This looks simple enough but I can not find out what I am doing wrong.

reg.
Axel

3 Answers, 1 is accepted

Sort by
0
Axel
Top achievements
Rank 2
answered on 26 Jan 2010, 11:30 PM
Hi again,

Also tried to do it this way (in PageLoad) without any luck. Even tried a different table this time.
This simple code is not working at my end. What can be wrong?

                PageManagementDataContext db = new PageManagementDataContext();  
                List<WebPage> x = db.WebPages.ToList();  
                RadTreeView1.DataTextField = "pagename";  
                RadTreeView1.DataFieldID = "id";  
                RadTreeView1.DataFieldParentID = "parentpageid";  
                RadTreeView1.DataSource = x;  
                RadTreeView1.DataBind();  
 

(Manually populating the nodes works but if databinding can be done then that's the way I sould do it.
0
Veselin Vasilev
Telerik team
answered on 28 Jan 2010, 01:52 PM
Hi AxelGunn,

I already replied to the ticket of yours.

Please download a sample project from here. Hope you will find it useful.
Greetings,
Veskoni
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.
0
Axel
Top achievements
Rank 2
answered on 28 Jan 2010, 02:17 PM
Thanks. 
Ending this one - will use the ticked for replies
Tags
TreeView
Asked by
Axel
Top achievements
Rank 2
Answers by
Axel
Top achievements
Rank 2
Veselin Vasilev
Telerik team
Share this question
or