动态创建的选项卡面板 [英] Dynamically Created Tab Panels
问题描述
你好
我有一个网页,其中包含一个TabContainer,然后在其中包含一个子TabContainer.
我希望能够基于SqlDataSource的结果动态填充子TabContainer中的某些选项卡.
例如:
SqlDataSource选择一个属于特定组的人的列表,我想在TabContainer的不同选项卡上显示每个成员
任何帮助,将不胜感激.
谢谢
Pete
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
推荐答案
我将以这种方式创建动态标签面板(它也可以在Page_Load事件处理程序中使用):
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);
}
这段代码对我来说很完美. tabContainer1控件的类型为AjaxControlToolkit.TabContainer,并在页面上通过以下方式声明:
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>
快乐编码:rose :: rose :: thumbsup::)
Happy Coding:rose::rose::thumbsup: :)
这篇关于动态创建的选项卡面板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!