Click here to Skip to main content
15,916,949 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi, I can create tab panels in tab container dynamically based on options user has selected from Listbox. Let's say there are 4 items in ListBox, 'Item1, Item2, Item3, Item4'. If user selected all 4 items, 4 tab panels will be created in tab container with header text as 'Item1, Item2, Item3, Item4', which is the option name in Listbox.

I would like to add content like chart to tab panel with specific header text. E.g. to add chart only to tab panel with header text 'Item1" only. How can I accomplish this?

This is my codes to create tab panel dynamically:

Aspx file:
<asp:listbox ID="SelectionListBox" runat="server" SelectionMode="Multiple" >
<asp:listitem>Select All</asp:listitem>
<asp:listitem>Item 1</asp:listitem>
<asp:listitem>Item 2</asp:listitem>
<asp:listitem>Item 3</asp:listitem>
<asp:listitem>Item 4</asp:listitem>

         <asp:scriptmanager ID="ScriptManager1" runat="server">
    <asp:updatepanel ID="UpdatePanel1" runat="server">

    <asp:placeholder ID="PlaceHolder1" runat="server"></asp:placeholder>

Cs file:
protected void RETRIEVE_BUTTON_Click(object sender, EventArgs e)
        AjaxControlToolkit.TabContainer container = new AjaxControlToolkit.TabContainer();
        container.ID = DateTime.Now.Millisecond.ToString();
        container.EnableViewState = false;
        container.Height = Unit.Pixel(500);
        container.Width = Unit.Pixel(1200);
        container.Tabs.AddAt(0, GetManualTab());

        foreach (ListItem item in SelectionListBox.Items)
            if (item.Selected)
                Label tabContent = new Label();
                tabContent.ID = "lbl_tab_";
                tabContent.Text += item.Value;

                AjaxControlToolkit.TabPanel panel = new AjaxControlToolkit.TabPanel();
                panel.HeaderText += item.Value;

    public AjaxControlToolkit.TabPanel GetManualTab()
        AjaxControlToolkit.TabPanel panel = new AjaxControlToolkit.TabPanel();
        return panel;

Question: How to add content like chart to tab panel with specific header text. For example: to add chart only to tab panel with header text 'Item1".

Appreciate if someone can help me on this, thanks a lot!!
Updated 26-Sep-15 9:26am
ramyajaya 26-Sep-15 17:16pm    
You can check if the header text is Item1 and add the chart to the tab panel before adding it to the container

Panel.controls. add(chartElement);

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