Hi,
I have a query (CTE) that returns the parent child relationship in a dataset and I can bind to an ASP.Net treeview but I want to be able to bind to a RadTreeView. Can anyone help me with the conversion?
Here's my code to bind to a treeview:
Does anyone know how to do this with a RadTreeView? I almost had it working but the newNode doesn't have a ChildNodes collection.
Thanks
I have a query (CTE) that returns the parent child relationship in a dataset and I can bind to an ASP.Net treeview but I want to be able to bind to a RadTreeView. Can anyone help me with the conversion?
Here's my code to bind to a treeview:
Private Sub InitializeControls() |
'==Get some info from the logged in user |
Dim oContact As New Contact(UserInstance.ContactID) |
'== Labels |
lblDownline.Text = "My Distributor Downline" |
LoadDataSet() |
'== If it's the root node, SponsorID will be zero so use their contactid |
Dim parentID As Integer = 0 |
If oContact.SponsorID = 0 Then |
parentID = UserInstance.ContactID |
Else |
parentID = oContact.SponsorID |
End If |
BuildTree(TreeView1.Nodes, parentID) |
End Sub |
Private Sub LoadDataSet() |
'==ds is declared at the page level |
Dim oContacts As New ContactCollection |
ds = oContacts.GetDownline(UserInstance.ContactID, 8) '==returns a dataset...later would like to return a collection |
End Sub |
Private Sub BuildTree(ByVal nodes As TreeNodeCollection, ByVal IntParent As Int32) |
Dim thisID As Int32 |
Dim thisName As String |
Dim children As DataRow() = ds.Tables(0).Select("SponsorID='" & IntParent & "'") |
If children.Length = 0 Then |
Return |
End If |
Dim newNode As TreeNode |
For Each child As DataRow In children |
thisID = Convert.ToInt32(child.ItemArray(0)) |
thisName = Convert.ToString(child.ItemArray(2)) |
newNode = New TreeNode(thisName, thisID.ToString) |
nodes.Add(newNode) |
newNode.ToggleExpandState() |
BuildTree(newNode.ChildNodes, thisID) |
Next |
End Sub |
Does anyone know how to do this with a RadTreeView? I almost had it working but the newNode doesn't have a ChildNodes collection.
Thanks