Hi
I need to dinamically add new tabs to a WebTab controls, and inside each tab add a custom Repeater Control, how can i do it?
Regards....
Hi Viktor Snezhko ,
I want to change the positions of the existing tabs dynamically. Please suggest how can we achieve it.
I tried with Insert and Add methods. Still not achieved.
Please let me know ASAP.
Thanks
Dan
We have 15 tabs loaded with values int he controls. Dynamically we need to change the position of the tabs. I am using the following code.
ContentTabItem Tab1 = new ContentTabItem(); ContentTabItem Tab2 = new ContentTabItem();
...
Tab1 = tabTest.Tabs.FindTabFromKey("Main"); Tab2 = tabTest.Tabs.FindTabFromKey("Book");
tabTest.Tabs.RemoveAt(0);tabTest.Tabs.RemoveAt(1);
tabTest.Tabs.Add(Tab1); // Throwing error
Or
tabTest.Tabs.Insert(0, Tab1); // Throwing Error
In the above code we are getting "Value cannot be null. Parameter name: The argument, CollectionObject, is not allowed to be null.
Please help us, how can we achieve this.
Regards
Hi Daniel,
The tabs which are used by WebTab are instances of Control, so you may add dynamic controls directly to them. The only thing you should keep in mind, that dynamically added tabs will persist but their content is not, because dot-net does not support persistance of controls, but only their view states. So, dynamic controls should be added in every postback by exactly same logic with exactly same IDs.Besides explicit controls you also may use UserControlUrl property of tab item, or load user control explicitly.Below is example for you:
protected void Page_Load(object sender, EventArgs e){ if (!this.IsPostBack) { for(int i = 0; i < 3; i++) { Infragistics.Web.UI.LayoutControls.ContentTabItem tab = new Infragistics.Web.UI.LayoutControls.ContentTabItem(); tab.Text = "Tab" + (i + 1); this.WebTab1.Tabs.Add(tab); } } int tabs = this.WebTab1.Tabs.Count; while (tabs-- > 0) this.FillTab(this.WebTab1.Tabs[tabs], tabs);}private void FillTab(Infragistics.Web.UI.LayoutControls.ContentTabItem tab, int index){ if(index == 0 || index == 2) { TextBox tb = new TextBox(); tb.ID = "TextBoxOnTab" + index; tb.Text = "initial text " + (index + 1); tab.Controls.Add(tb); } if(index == 1) { Button but = new Button(); but.ID = "ButtonOnTab" + index; but.Text = "Button on Tab " + (index + 1); tab.Controls.Add(but); } Repeater repeater = new Repeater(); repeater.ID = "repeaterOnTab" + index; //repeater.DataSourceID = "AccessDataSource1"; //BuildTemplateMethod builder = new BuildTemplateMethod(BuildControl); //CompiledTemplateBuilder template = new CompiledTemplateBuilder(builder); //repeater.ItemTemplate = template; tab.Controls.Add(repeater); //repeater.DataBind();}