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

Dynamic TabStrip/MultiPage/PageView

2 Answers 96 Views
TabStrip
This is a migrated thread and some comments may be shown as answers.
ADAPT
Top achievements
Rank 2
ADAPT asked on 07 Apr 2014, 03:40 PM
Hello Community!

I am trying to find a solution to dynamically create TabStrip with MultiPage and Pageviews with UserControls from a SQL database.

Here is what I have thus far.
SQL Table: ID, ParentID, TabName, URL, Position, NavBar, Page, and Active columns.
I store the path to the webpage and UserControls in the URL column.
The rest of the columns are for sorting and visibility per user/page/etc.

Here is my HeaderControl.ascx code.
<telerik:RadTabStrip ID="RadTabStrip1" runat="server" MultiPageID="RadMultiPage1" SelectedIndex="0" CausesValidation="False" Skin="Black" Width="100%"></telerik:RadTabStrip>
 
<telerik:RadMultiPage ID="RadMultiPage1" runat="server" SelectedIndex="0"></telerik:RadMultiPage>

Here is my codeBehind.
public int _Page;
 
protected void Page_Load(object sender, EventArgs e)
{
    int _FID = Convert.ToInt32(Session["_FID"]);
    int _AID = Convert.ToInt32(Session["_AID"]);
 
    IMasterPage masterPage = Page.Master as IMasterPage;
    if (masterPage.bodyID == "DB")
    {
        _Page = 1;
        Page.Title = string.Format("Virtual Law Desk :: Dashboard");
    }
    else if (masterPage.bodyID == "CM")
    {
        _Page = 2;
        Page.Title = string.Format("Virtual Law Desk :: Client Management");
    }
 
 
    StandardClass SC = new StandardClass();
    {
        if (!SC.IsError)
        {
            SC.ReturnLawfirmUser(_FID, _AID);
            {
                fnLbl.Text = SC.FirstName;
                lnLbl.Text = SC.LastName;
            }
        }
    }
 
    NavigationClass NC = new NavigationClass();
    {
        if (!NC.IsError)
        {
 
            RadMenu1.DataSource = NC.ReturnTabNavigation();
            RadMenu1.DataTextField = "tabname";
            RadMenu1.DataNavigateUrlField = "url";
            RadMenu1.DataValueField = "pid";
            RadMenu1.DataFieldID = "id";
            RadMenu1.DataBind();
 
            RadTabStrip1.DataSource = NC.ReturnSubTabNavigation(_Page);
            RadTabStrip1.DataTextField = "tabname";
            //RadTabStrip1.DataNavigateUrlField = "url";
            RadTabStrip1.DataValueField = "pid";
            RadTabStrip1.DataFieldID = "id";
            RadTabStrip1.SelectedIndex = -1;
            RadTabStrip1.DataBind();
 
            RadPageView pageView = new RadPageView();
            pageView.ID = "pid";
            RadMultiPage MultiPage1 = RadMultiPage1;
            MultiPage1.PageViews.Add(pageView);
 
            NC.ReturnUserControls(_Page);
            {
                Control userControl = Page.LoadControl(NC.URL);
                pageView.Controls.Add(userControl);
            }
        }
    }
}

All classes are derived from a class.dll file I have created. Everything work perfectly except the UserControls for each of the PageViews. Each Main Navigation when clicked on will produce Sub Navigation Tabs which works fine. The PageViews are created as well but each of those PageViews will have a different UserControl. These UserControls paths are read from the URL column in SQL. BAsed on the NC.ReturnUserControls Class how can I make this work? Am I missing an iteration or something like it?

Thanks for any replies!




2 Answers, 1 is accepted

Sort by
0
Plamen
Telerik team
answered on 10 Apr 2014, 11:29 AM
Hi,

The provided code is not enough to find our what exactly is not working correctly in your case. That is why I will recommend you to refer to this on-line demo where is explained exactly how we recommend adding dynamically tabs and multipages and compare your scenario accordingly.

Hope this will be helpful.

Regards,
Plamen
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
ADAPT
Top achievements
Rank 2
answered on 10 Apr 2014, 11:54 AM
I have been so busy I forgot I posted here. I actually came up with the solution. If anyone needs a snippet of code for this let me know.
Tags
TabStrip
Asked by
ADAPT
Top achievements
Rank 2
Answers by
Plamen
Telerik team
ADAPT
Top achievements
Rank 2
Share this question
or