Treeview in User Control

3 posts, 0 answers
  1. Joe Hakooz
    Joe Hakooz avatar
    65 posts
    Member since:
    Dec 2007

    Posted 16 Jan 2008 Link to this post

    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. Nikolay
    Admin
    Nikolay avatar
    3997 posts

    Posted 17 Jan 2008 Link to this post

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Joe Hakooz
    Joe Hakooz avatar
    65 posts
    Member since:
    Dec 2007

    Posted 17 Jan 2008 Link to this post

    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
Back to Top