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

RadPanelItem dynamically

1 Answer 120 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
Michael asked on 19 Mar 2010, 04:23 AM
I have a RadPanelBar with about 6 RadPanelItems -- each of these items are separate .ASCX user controls.  Within these user controls depending on the options selected by the user I want to have other RadPanelItems created dynamically (at run-time). 

The problem I'm having is that when added the RadPanelItem is expanded, but when clicked it collapses.  However, it then doesn't ever expand again (nor does it have the arrow pointing downward showing that there is something to expand).

Here is the code I use to add the items:

        RadPanelBar1 = Page.FindControl("RadPanelBar1")  
        Dim radPanelBarItem1 As New RadPanelItem  
        radPanelBarItem1.Text = "   Basic Network Configuration" 
        Dim template As ITemplate  
        radPanelBarItem1.ImageUrl = "../Images/basic_network.png" 
        template = Page.LoadTemplate("/controls/basicnet.ascx")  
        radPanelBarItem1.ItemTemplate = template  
        Dim template2 As ITemplate  
        Dim radPanelBarItem2 As New RadPanelItem  
        radPanelBarItem2.Expanded = False 
        radPanelBarItem2.Text = "   Advanced Network Configuration" 
        radPanelBarItem2.ImageUrl = "../Images/advanced_network.png" 
        template2 = Page.LoadTemplate("/controls/advnet.ascx")  
        radPanelBarItem2.ItemTemplate = template2  

The items show up obviously but like I said they're not functional.  It happens when the page is ajaxified and also when it's not ajaxified so I think it's definitely something I'm doing wrong.

Thanks for any help you can provide -- I've attached a screenshot.



1 Answer, 1 is accepted

Sort by
Telerik team
answered on 23 Mar 2010, 05:17 PM
Hello Michael,

You can load the UserControls dynamically, and then add them to ItemsCollection of the RadPanelItem:

Protected Overrides Sub OnLoad(ByVal e As System.EventArgs)
        Dim radPanelBarParentItem01 As New RadPanelItem()
        radPanelBarParentItem01.Text = "Basic Network Configuration"
        Dim userControl01 As Control = LoadControl("~/WebUserControl_01.ascx")
        Dim userControlItem01 As New RadPanelItem()
        radPanelBarParentItem01.Expanded = True
        Dim radPanelBarParentItem02 As New RadPanelItem()
        radPanelBarParentItem02.Text = "Advanced Network Configuration"
        Dim userControl02 As Control = LoadControl("~/WebUserControl_02.ascx")
        Dim userControlItem02 As New RadPanelItem()
    End Sub

Please find more details at sample page attached.

Best wishes,
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Asked by
Top achievements
Rank 1
Answers by
Telerik team
Share this question