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

RadMultiPage with asp:Repeater

2 Answers 203 Views
TabStrip
This is a migrated thread and some comments may be shown as answers.
tomo
Top achievements
Rank 1
tomo asked on 12 Jan 2009, 07:55 PM
Hello,

I am trying to create a dynamic tabstrip/multipage section of a page, where the tabs and radpageview instances are database driven. It is easy to bind the tabstrip to a data source, but I am really struggling with how to get a dynamic RadMultiPage. Because the content of each RadPageView is non-trivial, I do not want to build up the entire page view in code and would much rather use the templating capability of Repeater to do the heavy lifting.

But no matter how I play with the code, I cannot get it to do the right thing. I would like to have something like this:

<telerik:RadTabStrip ID="FormulaTabs" runat="server" MultiPageID="FormulaContexts" 
DataSourceID="ContextSource" DataTextField="qualifiedContextName" />

<telerik:RadMultiPage ID="FormulaContexts" runat="server">
<asp:Repeater ID="FormulaRepeater" runat="server" DataSourceID="ContextSource">
<ItemTemplate>
<telerik:RadPageView ID="FormulaPageSample" runat="server">
<asp:Label ID="Label2" runat="server" Text='<%# Eval("qualifiedContextName") %>' />
</telerik:RadPageView>
</ItemTemplate>
</asp:Repeater>
</telerik:RadMultiPage>

The goal is for the RadPageView to have content specific to the data source in the repeater and that, since the tabstrip is using the same data source and is pointing to the RadMultiPage, that the tabs would flip to the correct data. Of course, in the snippet above, VS complains because Repeater is not a recognized child element of RadMultiPage, and RadPageView is not a recognized child of Repeater. Putting RadMultiPage into the repeater's header template is equally invalid.

Is this at all possible?

Thanks, in advance,

Tom Otvos

2 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 13 Jan 2009, 09:52 AM
Hello tomo,

RadMultiPage can only have children of type RadPageView. You cannot nest arbitrary controls in it (such as Repeater). Also the repeater displays all its items at the same time which would defeat the purpose of RadTabStrip - to have tab pages based interface.

What you can do is subscribe to the TabDataBound event and generate RadPageView objects on the fly. Since the pageviews do not have a template you can create the controls in two ways:
  1. Use a template defined in code behind e.g.:

    public class MyTemplate : ITemplate
    {
         public void InstantiateIn(Control container)
         {
              Label myLabel = new Label();
              container.Controls.Add(myLabel);
         }
    }

    then in TabDataBound:

    RadPageView pageView = new RadPageView();
    RadMultiPage1.PageViews.Add(pageView);
    MyTemplate template = new MyTemplate();

    template.InstantiateIn(pageView);
  2. Instantiate controls and add them to the pageview's controls collection:
    Label myLabel = new Label();
    pageView.Controls.Add(myLabel);

Greetings,
Albert
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Arsen
Top achievements
Rank 1
answered on 19 Nov 2009, 09:06 AM
What is the best way to generate tabs from an xml document?
The doc is 3 layers deep.
The first layer would be used for tab names
The second layer would be used to for a horizontal datalist inside the tab
The third layer would be used for datagrids that are part of the datalist.
Tags
TabStrip
Asked by
tomo
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Arsen
Top achievements
Rank 1
Share this question
or