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

RadTabStrip

1 Answer 55 Views
TabStrip
This is a migrated thread and some comments may be shown as answers.
Dev
Top achievements
Rank 1
Dev asked on 06 Feb 2013, 02:54 AM
Hi,
I have a rad strip defined on my aspx page as follows,
<telerik:RadTabStrip ID="radTabStripSamples" runat="server" OnTabClick="radStripHardwareBrowser_Click"/>

I am generating the tabs for the above tabstrip using C# code as follows
protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            List<Category> lstCategories = new List<Category>();
            lstCategories = Service.GetCategories();
            int numberOfCategories = lstCategories.Count;
            CreateTabs(numberOfCategories, lstCategories);
        }
    }
 
protected void CreateTabs(int numberOfCategories, List<Category> lstCategories)
    {
        for (int i = 0; i < numberOfCategories; i++)
        {
            RadTab tab = new RadTab(lstCategories[i].Name);
            radTabStripSamples.Tabs.Add(tab);
        }
    }
now i would like to add template to each of those rad tabs as in static code say for example 
<telerik:RadTabStrip ID="radTabStripSamples" runat="server" OnTabClick="radStripHardwareBrowser_Click">

<Tabs>
        <telerik:RadTab Text="Sample1" runat="server">
        <TabTemplate>
            <table>
  //would like to generate this table inside the tab template of the individual tab from cs code //
           </table>
        </TabTemplate>
        </telerik:RadTab>
</Tabs>
</telerik:RadTabStrip

from C# code, after adding the tabs dynamically.So,I tried something like this 
RadTemplateItem template = new RadTemplateItem();
tab.TabTemplate = template.InstantiateIn(tab);//-----> //this would nt work for sure because the return type is void. So would like to know how to go about this.
 tab.TabTemplate =  template;//--->//This one did not work the way i expected it to// this simply replaced the tab name with "XyZ serires" instead of the categories names.

class RadTemplateItem : ITemplate
{
    public void InstantiateIn(Control container)
    {
        Table tbl = new Table();
        TableRow row = new TableRow();
        TableCell cell = new TableCell();
        Label Name = new Label();
        Name.Text = "XYZ Series";
        cell.Text = Name.Text;
        row.Cells.Add(cell);
        tbl.Rows.Add(row);
        container.Controls.Add(tbl);
    }
 
}
I do not know whether am using the right approach.Would like to see a sample to do the same or any documentation. Thanks you for your help

1 Answer, 1 is accepted

Sort by
0
Plamen
Telerik team
answered on 08 Feb 2013, 03:32 PM
Hello,

 
Here is the help article that should be helpful. Please let me know if you have further questions.

All the best,
Plamen
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
TabStrip
Asked by
Dev
Top achievements
Rank 1
Answers by
Plamen
Telerik team
Share this question
or