RadMultiPage with asp:Repeater

3 posts, 0 answers
  1. tomo
    tomo avatar
    2 posts
    Member since:
    Mar 2007

    Posted 12 Jan 2009 Link to this post

    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. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 13 Jan 2009 Link to this post

    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.
  3. Arsen
    Arsen avatar
    1 posts
    Member since:
    Nov 2009

    Posted 19 Nov 2009 Link to this post

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