Click here to Skip to main content
15,896,201 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello

I have a webpage that contains a TabContainer and then a sub TabContainer inside that.

I want to be able to populate some of the tabs in the sub TabContainer dynamically based on the results of a SqlDataSource.

For Example:

The SqlDataSource selects a list of people who belong a particular group, I want to show each member on a different Tab of the TabContainer

Any help on this would be appreciated.

Thanks

Pete
Posted
Comments
Sandeep Mewara 24-Nov-10 6:20am    
Ok. So you tried anything to do it?
Sunasara Imdadhusen 24-Nov-10 7:08am    
Please try yourself, then ask for help if you are stuck anywhere!!

1 solution

Hi,

I'd do this dynamic tab panel creation this way (it also works in the Page_Load event handler):



protected override void OnInit(EventArgs e)
{
    base.OnInit(e);

    // Create the tab panel's content container
    Control tabContent = new Control();

    TabPanel tab = new TabPanel();
    tab.ID = "tabPanel1";
    tab.HeaderText = "Dynamic Panel";

    Label label = new Label();
    label.Text = "This is a dynamic tab panel";
    tabContent.Controls.Add(label);
    tab.Controls.Add(tabContent);
    this.tabContainer1.Tabs.Add(tab);
}




This pice of code works for me perfect. The tabContainer1 control is of type AjaxControlToolkit.TabContainer and is declared on the page this way:



<ajaxcc:TabContainer ID="tabContainer1" runat="server">
</ajaxcc:TabContainer>




Happy Coding:rose::rose::thumbsup: :)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900