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

Problem with dynamically added controls.

3 Answers 42 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
Yura
Top achievements
Rank 1
Yura asked on 11 May 2012, 11:44 AM
Hi.
I create a panel bar item, and attach ItemTemplate to it in the code-behind.
Everything looks ok, controls added to panel bar display just fine, but when i try to access them in code-behind (after a button on page being clicked) RadPanelITem that contains dynamically added controls doesn't show them anymore, its Controls collection is empty (but it's not empty after i add the controls) and findControl returns null.
What am i doing wrong?

3 Answers, 1 is accepted

Sort by
0
Yura
Top achievements
Rank 1
answered on 11 May 2012, 12:05 PM
My guess is that since template should be instantiated upon a postback, which happens when i click a button on the page, the contens of RadPanelItem is cleared. The question is, how can I access data entered in dynamically added controls when i click the abovementioned button?
0
Yura
Top achievements
Rank 1
answered on 12 May 2012, 08:08 AM
Further research shows the following:
It doesn't really matter whether controls are added dynamically directly to radPanelItem, or created in InstantiateIn method of ItemTemplate which is assigned to radPanelItem mentioned above, the controls "won't be there" during postback.
Please, help.
0
Dimitar Terziev
Telerik team
answered on 16 May 2012, 07:32 AM
Hi Yura,

In general the template controls could be accessed as shown in the following help article here. Please note that in case a ContentTemplate is used the template controls could be access directly by ID.

Kind regards,
Dimitar Terziev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
PanelBar
Asked by
Yura
Top achievements
Rank 1
Answers by
Yura
Top achievements
Rank 1
Dimitar Terziev
Telerik team
Share this question
or