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

Expanding DataBound items with ItemTemplate

1 Answer 79 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
ile
Top achievements
Rank 1
ile asked on 14 Oct 2010, 08:35 AM
Hi,

I'm using RadPanelBar Q1 2010 SP2. and having following scenario: I'm binding the top level items to List<T>. Then under each item I'd like to add ItemTemplate with quite a lot of controls inside (TextBoxes, GridView, etc.) so adding them dynamically in .cs isn't an option. Problem is that following declarative syntax displays right but doesn't expand :

ASPX:
<telerik:RadPanelBar ID="RadPanelBar1" runat="server" Skin="Vista" ExpandMode="FullExpandedItem" DataFieldParentID="Id" DataTextField="Name">
    <ItemTemplate>
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
    </ItemTemplate>
</telerik:RadPanelBar>

CS:
ObjectiveCollection objectives = user.Objectives;
RadPanelBar1.DataSource = objectives;
RadPanelBar1.DataBind();

1 Answer, 1 is accepted

Sort by
0
Nikolay Tsenkov
Telerik team
answered on 19 Oct 2010, 09:57 AM
Hello ile,

The right way to implement this requirement is to create the templates in the code-behind as classes implementing the ITemplate interface. Here is a nice article that should give you an idea: http://www.telerik.com/help/aspnet-ajax/tree_templatesruntime.html

After you implement that you can create a handler to the TemplateNeeded event of the panelBar (it will be thrown for every item that is created from the dataSource, separately) and there you will have the item (in the event arguments), so you can decide which template should it take. Here is a nice reference for this event: http://www.telerik.com/help/aspnet-ajax/telerik.web.ui-telerik.web.ui.radpanelbar-templateneeded_ev.html

Hope this is helpful for you!


Regards,
Nikolay Tsenkov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
PanelBar
Asked by
ile
Top achievements
Rank 1
Answers by
Nikolay Tsenkov
Telerik team
Share this question
or