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

accessing dynamically generated controls inside a PanelBarItem

2 Answers 67 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
Christopher
Top achievements
Rank 1
Christopher asked on 17 Jun 2009, 04:13 AM
I'm having trouble getting to the RadioButtonList control that is added dynamically when the page loads.
Here's a snippet of code that creates a RadPanelItem, add a RadioButtonList control to it, and then adds that to the RadPanelBar:

Dim

 

rdiobtnList As New RadioButtonList

 

rdiobtnList.ID =

"AssignmentRadioBtnList"

 

 

For Each Assignmentsdr As DataRow In AssignmentsDataSet.Tables(0).Rows

 

RowCount += 1

 

Dim li As New ListItem

 

li.Value = Assignmentsdr.Item(

"AssignmentListID")

 

li.Text = Assignmentsdr.Item(

"Assignment")

 

li.Selected =

False

 

rdiobtnList.Items.Add(li)

 

Next

 

 

Dim AssignmentPanelItem As New RadPanelItem

 

AssignmentPanelItem.Value =

"Assignments"

 

AssignmentPanelItem.Controls.Add(rdiobtnList)

AssignmentsRadPanelBar.Items.Add(AssignmentPanelItem)

 

Here is how I have the ASPX page setup:

 

 

<telerik:RadPanelBar ID="AssignmentsRadPanelBar" Runat="server" Skin="Web20" Width="150px">

 

 

 

    <CollapseAnimation Duration="100" Type="Linear" />

 

 

 

    <ExpandAnimation Duration="100" Type="Linear" />

 

 

 

</telerik:RadPanelBar>

I've looked through the FAQ's and the Tutorials, but none of the tutorials touch on adding RADPanelItems dynamically.

Any help would be very much appreciated.

 

 

 

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 17 Jun 2009, 12:03 PM
Hello Christopher,

Try the following code snippet for accessing the RadioButtonList placed in RadPanelItem.

CS:
 
protected void Button1_Click(object sender, EventArgs e) 
    RadPanelItem item = AssignmentsRadPanelBar.Items[0]; 
    RadioButtonList rdiobtnList1 = (RadioButtonList) item.FindControl("AssignmentRadioBtnList"); 

Shinu
0
Christopher
Top achievements
Rank 1
answered on 17 Jun 2009, 12:46 PM
Thanks Shinu.
However, the rdiobtnList1 is empty (nothing).  The code definitely accesses the RadioButtonList I added to the PanelItem, but there isn't anything there.  I don't understand.  Also, when the page loads, the radio buttons themselves show on the screen but not the text associated with them?

Any ideas?
Tags
PanelBar
Asked by
Christopher
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Christopher
Top achievements
Rank 1
Share this question
or