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

Trouble with hierarchical data binding

6 Answers 113 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
pbarron
Top achievements
Rank 1
pbarron asked on 02 Sep 2008, 02:33 PM
Hi,

I'm having trouble binding using a hierarchical datasource.
The menu is showing the items from the database, however they are all showing as first level items rather than sub-levels/child-items.
Please help - am sure I'm missing something very obvious!

ASPX code is:

<telerik:RadPanelBar ID="RadPanelBar1" runat="server" ExpandAnimation-Type="InQuart" CollapseAnimation-Type="InOutQuart" ExpandMode="SingleExpandedItem" PersistStateInCookie="true" Skin="Default"></telerik:RadPanelBar>

C# code is:

public void setSideMenu(){
    var d = db.vptblIntranetMenuSelect();
    RadPanelBar1.DataFieldID =
"id";
    RadPanelBar1.DataFieldParentID =
"parentid";    
    RadPanelBar1.DataNavigateUrlField =
"url";
    RadPanelBar1.DataTextField =
"menu";
    RadPanelBar1.DataSource = d;
    RadPanelBar1.DataBind();
    RadPanelBar1.Items[1].Expanded =
true;
}


6 Answers, 1 is accepted

Sort by
0
Daniel
Top achievements
Rank 1
answered on 02 Sep 2008, 07:41 PM
I'm having the same problem.

<telerik:RadPanelBar ID="rpbVideos" runat="server" expandMode="SingleExpandedItem"> </telerik:RadPanelBar>

VB.Net Code:

With rpbVideos 
    .DataTextField = "Title"   
    .DataFieldID = "ID"   
    .DataFieldParentID = "ParentID"   
    .DataSource = myItems 
    .DataBind() 
    .Items(0).Expanded = False
End With
0
Yana
Telerik team
answered on 03 Sep 2008, 11:25 AM
Hello,

Please check the attached sample project which demonstrates hierarchical data binding. Download it and give it a try.

Greetings,
Yana
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Aydın Kara
Top achievements
Rank 1
answered on 05 Sep 2008, 01:43 PM
Hi,

I have totally the same problem.
I tried everything that is described at http://www.telerik.com/help/aspnet-ajax/panel_dataobjectdatasources.html.
But unfortunately the child items are displayed as root items.

Update: I tried to bind parent id field to an unknown field which doesnt exist on my object. 

pnlBarAramaSonuclari.DataFieldParentID =

"ParentID2";

Code doesn't give any error.

Then I tried the same thing on Text field.

pnlBarAramaSonuclari.DataTextField =

"Text2";

It gave an error: 'AramaKullaniciKontrolu.AramaSonucu' does not contain a property with the name 'Text2'

It seems that radpanelbar doesnt bind parentid..

Thanks,

Kerem
0
Daniel
Top achievements
Rank 1
answered on 08 Sep 2008, 09:30 PM
I tried the attached sample and it works.  However if I change the data source from a data set to a collection of objects it breaks and will no longer nest the data.

I simply took your sample and used LINQ To SQL to retrieve the data as opposed to the dataset.  I'm still using the Links table and so the data is the same.  Just now it is in a collection of objects as opposed to a dataset.
0
Atanas Korchev
Telerik team
answered on 09 Sep 2008, 07:29 AM
Hello Daniel,

The attached sample is using an older version (Q1 2008 SP2). In order to bind to LINQ you need the current official release (Q2 2008 SP1). Please find attached the modified example. You can download the latest version of RadControls for ASP.NET Ajax from your client.net account.

Regards,
Albert
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Steve
Top achievements
Rank 1
answered on 10 Sep 2008, 02:23 PM
Using SP1 of Q2 has resolved the issue.  Thanks for the help.
Tags
PanelBar
Asked by
pbarron
Top achievements
Rank 1
Answers by
Daniel
Top achievements
Rank 1
Yana
Telerik team
Aydın Kara
Top achievements
Rank 1
Atanas Korchev
Telerik team
Steve
Top achievements
Rank 1
Share this question
or