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

Treeview in User Control

2 Answers 83 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Joe
Top achievements
Rank 2
Joe asked on 17 Jan 2008, 05:39 AM

Hi,
I'm using Prometheus Treeview including the Hotfix dll released yesterday. My code is VB and I'm populating the treeview in the codebehind.

Using an aspx page works just fine. When I move the code to a user control the treeview is empty. No errors, just empty. The user control is loading because I can see treeview in the html sourcecode.

Here are more details if that helps. I'm happy to provide more if needed.

--- aspx codebehind (works) ----

Imports System
Imports System.Data
Imports Telerik.Web.UI
Imports System.Data.SqlClient
Imports System.Configuration
Namespace Telerik.Web.Examples.TreeView.Databinding
Partial Public Class DefaultVB
Inherits System.Web.UI.Page
Private Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
If Not Page.IsPostBack Then
Dim adapter As New SqlDataAdapter("SELECT * FROM tbl_content", System.Configuration.ConfigurationManager.ConnectionStrings("cnstr").ConnectionString)
Dim links As New DataSet()
adapter.Fill(links)
RadTreeView1.DataTextField = "menuTitle"
RadTreeView1.DataFieldID = "id"
RadTreeView1.DataFieldParentID = "parent"
RadTreeView1.DataSource = links
RadTreeView1.DataBind()
End If
End Sub
End Class
End Namespace

--- user control codebehind (does not work) ----

Imports System
Imports System.Data
Imports Telerik.Web.UI
Imports System.Data.SqlClient
Imports System.Configuration
Partial Public Class webadmin_controls_pages_treeview
Inherits System.Web.UI.UserControl
Private Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
If Not Page.IsPostBack Then
Dim adapter As New SqlDataAdapter("SELECT * FROM tbl_content", System.Configuration.ConfigurationManager.ConnectionStrings("cnstr").ConnectionString)
Dim links As New DataSet()
adapter.Fill(links)
RadTreeView1.DataTextField = "menuTitle"
RadTreeView1.DataFieldID = "id"
RadTreeView1.DataFieldParentID = "parent"
RadTreeView1.DataSource = links
RadTreeView1.DataBind()
End If
End Sub
End Class

Again, if I need to provide any more code please let me know.
Thanks for any help,
Joe

2 Answers, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 17 Jan 2008, 08:23 AM
Hi Joe Hakooz,

I tried to reproduce the problem at our side, but to no avail.

Attached, please find a small and running project on the matter. Download it and give it a go.

I hope this will get you started.

Regards,
Nick
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Joe
Top achievements
Rank 2
answered on 17 Jan 2008, 02:38 PM
Thanks Nick. Problem solved!

I'd love to post what the problem was but I'm not sure. I started with your code, migrated it into my application, slowly but surely, and it works!

I suspect that using a data table as the treeview datasource, instead of using a dataset like I had been doing, resolved it...?

Thanks again
Tags
TreeView
Asked by
Joe
Top achievements
Rank 2
Answers by
Nikolay
Telerik team
Joe
Top achievements
Rank 2
Share this question
or