This is a migrated thread and some comments may be shown as answers.
Nested Controls in Databound RadPanel
2 Answers 45 Views
This is a migrated thread and some comments may be shown as answers.
Landon Martin
Top achievements
Rank 1
Landon Martin asked on 07 Oct 2009, 08:57 PM
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:

http://www.telerik.com/help/aspnet-ajax/panel_templatesoverview.html


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">  
    <ItemTemplate>            
      <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" /> 
                </ItemTemplate>                 
</telerik:RadPanelBar> 
 

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

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 Answers, 1 is accepted

Sort by
0
Paul
Telerik team
answered on 08 Oct 2009, 08:36 AM
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,
Paul
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.
0
Landon Martin
Top achievements
Rank 1
answered on 08 Oct 2009, 02:09 PM
Thanks for your reply! I actually found something on your site that was more in line with what I wanted here:
http://www.telerik.com/community/code-library/aspnet-ajax/panelbar/expandable-dynamic-items-with-templates.aspx
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.
Asked by
Landon Martin
Top achievements
Rank 1
Answers by
Paul
Telerik team
Landon Martin
Top achievements
Rank 1
Share this question
or