1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / TabStrip / MultiPage vs. lists

TabStrip / MultiPage vs. lists

2 posts, 0 answered
  1. Jiri
    Jiri avatar
    3 posts
    Registered:
    12 Mar 2008
    30 Jun 2008
    Link to this post
    Hello,

    do someone have an implementation of TabStrip and MultiPage to show the generic content e.g. from sitefinity lists? Something similiar and easy to use like Content View control?
    Is it possible to do the data binding to tabstrip and multi page controls with some list datasource control?

    thanks

    Jiri
  2. Pepi
    Pepi avatar
    981 posts
    Registered:
    31 Jan 2017
    01 Jul 2008
    Link to this post
    Hi Jiri,

    Here is a simple example how to achieve the required functionality using the API of the Lists module:

    .ascx
    <%@ Control Language="C#" AutoEventWireup="true" CodeFile="ListsView.ascx.cs" Inherits="UserControls_Custom_Controls_ListsView" %> 
     
    <telerik:RadTabStrip ID="RadTabstrip1" runat="server" MultiPageID="RadMultiPage1" EnableViewState="false"
    </telerik:RadTabStrip> 
    <telerik:RadMultiPage ID="RadMultiPage1" runat="server" SelectedIndex="0" OnPageViewCreated="RadMultiPage1_PageViewCreated"
    </telerik:RadMultiPage> 

    .ascx.cs
    using Telerik.Lists; 
    using Telerik.Web.UI; 
     
    public partial class UserControls_Custom_Controls_ListsView : System.Web.UI.UserControl 
        protected void Page_Load(object sender, EventArgs e) 
        { 
            this.manager = new ListManager(); 
     
            foreach(INamedList list in manager.GetLists()) 
            { 
                this.AddTab(list.Name, list.ID.ToString()); 
            } 
        } 
     
        private void AddTab(string tabName, string value) 
        { 
            RadTab tab = new RadTab(); 
            tab.Text = tabName; 
            tab.Value = value; 
            RadTabstrip1.Tabs.Add(tab); 
     
            RadPageView pageView = new RadPageView(); 
            pageView.ID = value.Replace("-""_"); 
            RadMultiPage1.PageViews.Add(pageView); 
        } 
     
        protected void RadMultiPage1_PageViewCreated(object sender, RadMultiPageEventArgs e) 
        { 
            Guid listId = new Guid(e.PageView.ID.Replace("_""-")); 
             
            Repeater repater = new Repeater(); 
            repater.DataSource = this.manager.GetListItems(listId); 
            repater.ItemCreated += new RepeaterItemEventHandler(repater_ItemCreated); 
            repater.DataBind(); 
     
            e.PageView.Controls.Add(repater); 
        } 
     
        void repater_ItemCreated(object sender, RepeaterItemEventArgs e) 
        { 
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) 
            { 
                e.Item.Controls.Add(new LiteralControl("<div><b>" + (e.Item.DataItem as IListItem).Headline + "</b></div>")); 
            } 
        } 
     
        private ListManager manager; 

    The example is a user control that generates a tab for each list. Clicking the tab enlists the item headlines of the corresponding list. You can modify the user control and make it more complex in order to display the necessary data for the list items.

    Hope this helps.

    Kind regards,
    Pepi
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
2 posts, 0 answered