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

Multi-Table DataSet

1 Answer 115 Views
TabStrip
This is a migrated thread and some comments may be shown as answers.
SDI
Top achievements
Rank 1
SDI asked on 18 Jun 2012, 03:39 PM
Hello Telerik,

According to the documentation the RadTabStrip should be able to bind to a dataset correct? I cant seem to get it to work correctly.

Dim myDataSet As New DataSet()
Dim table As New DataTable("ParentTbl")
Dim table1 As New DataTable("ChildTbl")
 
table.Columns.Add("ParentId")
table.Columns.Add("Name")
 
table.Rows.Add(New String() {"1", "root 1"})
table.Rows.Add(New String() {"2", "root 2"})
table.Rows.Add(New String() {"3", "root 3"})
table.Rows.Add(New String() {"4", "root 4"})
 
table1.Columns.Add("ChildId")
table1.Columns.Add("ParentId")
table1.Columns.Add("Name")
 
table1.Rows.Add(New String() {"1", "1", "child 1"})
table1.Rows.Add(New String() {"2", "1", "child 11"})
table1.Rows.Add(New String() {"3", "2", "child 2"})
table1.Rows.Add(New String() {"4", "2", "child 22"})
table1.Rows.Add(New String() {"5", "2", "child 23"})
table1.Rows.Add(New String() {"6", "3", "child 3"})
table1.Rows.Add(New String() {"7", "4", "child 4"})
table1.Rows.Add(New String() {"8", "4", "child 42"})
 
myDataSet.Tables.AddRange(New DataTable() {table, table1})
 
Dim myParentColumn As DataColumn = myDataSet.Tables(0).Columns("ParentId")
Dim myChildColumn As DataColumn = myDataSet.Tables(1).Columns("ParentId")
Dim myDataRelations As New DataRelation("myDataRelation", myParentColumn, myChildColumn)
myDataSet.Relations.Add(myDataRelations)
 
Me.RadTabStripReports.DataFieldParentID = "ParentId"
Me.RadTabStripReports.DataFieldID = "ChildId"
 
' Set Text, Value
Me.RadTabStripReports.DataTextField = "Name"
Me.RadTabStripReports.DataValueField = "ChildId"
 
Me.RadTabStripReports.DataSource = myDataSet
 
Me.RadTabStripReports.DataBind()

When I test the TabStrip with this code it blows out with an error on the DataBind line.

Columns specified by DataFieldID/DataFieldParenID not found. Is this because of multiple tables in the dataset? The sample you show only has 1 datatable in the dataset. I can debug it and see the columns do in fact exist in the dataset tables.

Can you supply a sample that works with multiple tables, or is there something else that needs to be done?

Thanks!

1 Answer, 1 is accepted

Sort by
0
Dimitar Terziev
Telerik team
answered on 21 Jun 2012, 09:04 AM
Hi,

The hierarchical binding of the RadTabStrip is supported in scenarios with self-referencing hierarchy in a single table. In scenario with multiple tables the hierarchy should be build manually by first creating the parent items and then adding their children.

Greetings,
Dimitar Terziev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
TabStrip
Asked by
SDI
Top achievements
Rank 1
Answers by
Dimitar Terziev
Telerik team
Share this question
or