Adding web user controls to RadPanelItem dynamically

2 posts, 0 answers
  1. Casey
    Casey avatar
    19 posts
    Member since:
    May 2011

    Posted 03 Feb 2012 Link to this post

    Does anyone have an example of how to dynamically add a web user control to a RadPanel? I have the following code, but it does not like how I am assigning the control. Does anyone have any ideas or a better way of doing this?
    Dim mainItem As New RadPanelItem()
    mainItem.Text = "Parent"
    mainItem.Expanded = True

    Dim secItem As New RadPanelItem()
    secItem.Text = "Child"
    secItem.Expanded = True

    Dim control As New RadPanelItem()
    Dim uc As Control = Page.LoadControl("~/WebUserControls/Panels/pnl_Selection.ascx")
    uc.ID = "ucSelection"

  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 06 Feb 2012 Link to this post


    Try the following code snippet.

    Protected Sub Page_Load(sender As Object, e As EventArgs
        Dim dataitem1 As New RadPanelItem()
        dataitem1.Text = "Text"
        Dim control As New RadPanelItem()
        Dim Panel1 As New Panel()
        Dim myControl As Control = LoadControl("~/WebUserControls/Panels/pnl_Selection.ascx")
    End Sub

Back to Top