1

I have a scenairo where I need to bind a RadPanelBar to a SQL table similar to the below structure:

ID, Name, Category 
1, Fred, Male 
2, Sam, Male 
3, Fred, Male 
4, Sam, Female
5, Louise, Female 
6, Tom, Male 

I need the panelbar to be in a Category > Name structure (i.e. each name to be a child item of their gender) but can't see an easy way to do this from Telerik's examples.

Any help/suggestions would be greatly appreciated.

Thanks in advance.

Mykola
  • 3,343
  • 6
  • 23
  • 39
Robert W
  • 2,921
  • 7
  • 34
  • 42

1 Answers1

0

You should look at the Data Bindings example and the Hierarchical Data Binding example.

Each item in the RadPanelBar has an item id. For child items you have to define a parent id also. The problem is that the database table does not have root items (male, female) stored as rows, so you have to add them first before binding to a RadPanelBar.

You can read the database table into a list or dataset, like in the example, and add the missing root items there.

Or, if you are using declarative binding (in ASPX), you can use UNION statements in a SQL query:

SELECT 
id
,CASE WHEN Category = 'Male' THEN -1 ELSE -2 END AS ParentID
,name
FROM table

UNION

SELECT 
-1 AS id
NULL As ParentID
'Male' AS name

UNION

SELECT 
-2 AS id
NULL As ParentID
'Female' AS name
mika
  • 6,812
  • 4
  • 35
  • 38