Problem with dynamically added controls.

4 posts, 0 answers
  1. Yura
    Yura avatar
    6 posts
    Member since:
    Mar 2012

    Posted 11 May 2012 Link to this post

    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?
  2. Yura
    Yura avatar
    6 posts
    Member since:
    Mar 2012

    Posted 11 May 2012 Link to this post

    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?
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Yura
    Yura avatar
    6 posts
    Member since:
    Mar 2012

    Posted 12 May 2012 Link to this post

    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.
  5. Dimitar Terziev
    Admin
    Dimitar Terziev avatar
    1266 posts

    Posted 16 May 2012 Link to this post

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