|
Rank: Member Groups: Member
Joined: 8/9/2007 Posts: 18
|
Hi EO, I'm having trouble getting the nested relation (parent/child) mode to work for either the menu or treeview controls. I've set everything up as per the example code, but rather than my nested item appearing under the first menu/tree item, it's appearing at the end with subitems of the same name.
Code: HTML/ASPX
<form id="form1" runat="server">
<div>
<eo:Menu id="Menu1" runat="server" controlskinid="MSDN" width="360px">
<TopGroup>
<Bindings>
<eo:DataBinding datafield="fRecId" property="Value" />
<eo:DataBinding datafield="fPageTitle" property="Text" />
</Bindings>
</TopGroup>
</eo:Menu>
<br />
<eo:TreeView id="treContent" runat="server">
<TopGroup>
<Bindings>
<eo:DataBinding datafield="fRecId" property="Value" />
<eo:DataBinding datafield="fPageTitle" property="Text" />
</Bindings>
</TopGroup>
</eo:TreeView>
</div>
</form>
Code: Visual Basic.NET
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
PopulateTree()
End Sub
#Region " Populate Tree "
Private Sub PopulateTree()
Dim myContent As New Content
Dim parentChild As DataRelation
With New ContentTableAdapters.tContentTableAdapter
.Fill(myContent.tContent)
End With
parentChild = myContent.Relations.Add(myContent.tContent.fRecIdColumn, myContent.tContent.fParentColumn)
parentChild.Nested = True
treContent.DataSource = myContent.tContent
treContent.DataBind()
Menu1.DataSource = myContent.tContent
Menu1.DataBind()
End Sub
#End Region
Code: Visual Basic.NET
fRecId fParent fPageTitle
1 NULL Homepage
2 NULL Links
3 1 Nested Page
I thought I had all this working perfectly, but apparently not. Am I missing something? Regards, Richard.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi Richard,
It appears that you are setting DataSource to "myContent.tContent". Try to set it to "myContent". Parent/Child relationship works when DataSource is a DataSet, not DataTable.
Thanks
|
|
Rank: Member Groups: Member
Joined: 8/9/2007 Posts: 18
|
lol, now I feel like a right plonker.
All working now, thanks for the speedy reply as always.
Regards,
Richard.
|
|
Rank: Member Groups: Member
Joined: 8/9/2007 Posts: 18
|
As a side note, one of my datasets has two tables (tCategories and tProducts) with a relationship between them. The tCategories table has a nested relationship, which is the one I'd like to bind. If I try and databind the dataset I get an exception as follows:
There are multiple top level tables in the data set. Please either set all Relation's Nested to true or set DataKeyFields property to ensure there is only one top level table.
It would be preferable not to have to seperate them into different datasets just to support the controls. So perhaps a useful new feature would be the ability to specify which table and indeed the nested relationship name the control should use when databinding to the whole dataset.
If you do implement this feature, I'd be more than happy to beta test it for you if required.
Regards,
Richard.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi Richard,
What you suggested makes perfect sense. We will look into it and see if we can put that together.
Thanks
|
|