Nested Controls in Databound RadPanel

3 posts, 0 answers
  1. Landon Martin
    Landon Martin avatar
    6 posts
    Member since:
    Oct 2009

    Posted 07 Oct 2009 Link to this post

    Hello, I'm having a bit of trouble trying to put nested controls in a databound RadPanel. What I want is basically the same as this example:

    However, the problem is that I do not know how many items I'm going to have until run time.

    If I have

    <telerik:RadPanelBar ID="RadPanelBar1" runat="server" ItemCreated="RadPanelBar1_ItemCreated">  
          <asp:TextBox ID="txtResponse" TextMode="MultiLine" runat="server" /><br /> 
          <asp:Button ID="btnSubmit" runat="server" Text="Submit" Visible="true" /> 
          <asp:LinkButton ID="lbAsk" runat="server" Visible="true" /> 
          <asp:LinkButton ID="lbNewEvisit" runat="server" Visible="true" /> 

    and my codebehind looks like
    protected void RadPanelBar1_ItemCreated(object sender, RadPanelBarEventArgs e)  
          if (e.Item.Owner is RadPanelBar)  
               RadPanelItem i = new RadPanelItem();  
    /* Page Load Event and other stuff */ 
    RadPanelBar1.DataSource = ds.Tables[0];  
    RadPanelBar1.DataTextField = "dtEvisitStart";  

    What happens is that the item template is created correctly for each item, with each item heading correct, however there's a duplicate set of controls attached to each item as seen on the attached image (each date should only have one set of controls).
    I see similar behavior in static code if I remove the empty ItemTemplate place holder, but I can't seem to correct the problem for the dynamically bound panel. Any help greatly appreciated! Thank you.
  2. Paul
    Paul avatar
    4281 posts

    Posted 08 Oct 2009 Link to this post

    Hi Landon Martin,

    The problem is that the template is added to both root items and their child items (which doesn't have any text); that's why you see the template twice. In order to achieve your goal, you will have to add all controls dynamically in code-behind to the child item(s) only.

    All the best,
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. Telerik UI for ASP.NET Core is out
  4. Landon Martin
    Landon Martin avatar
    6 posts
    Member since:
    Oct 2009

    Posted 08 Oct 2009 Link to this post

    Thanks for your reply! I actually found something on your site that was more in line with what I wanted here:
    This way I can define the template file in mark up.  It works great except for one thing that I think might be a bug.  When I have a textbox inside the template, and type say "23" into the textbox. While the panel is collapsing the 23 hangs in the middle of nowhere (even tho the textbox is hidden) until the collapsing animation is complete.

    After the animation is completed it disappears as it should.  For now, we have fixed it by turning off the animations, but I was wondering if this is a known issue?

    UPDATE: I've realized that the example I linked to does not have this problem, so I'm guessing it's a style issue creating a bug with IE?
    Not sure, but I don't think it relates directly to the control.  However, if anyone has any insights I'll take them. Thanks.
Back to Top