dynamically generated pageview issue
Posted
by user203127
on Stack Overflow
See other posts from Stack Overflow
or by user203127
Published on 2010-05-24T19:00:59Z
Indexed on
2010/05/25
7:01 UTC
Read the original article
Hit count: 332
telerik
hi,
I have created dynamic tab function. When i create dynamic tab it will create pageview for that tab. But when i deleted that tab that pageview is not deleting. Can any one help me to fix this.
using System;
using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using Telerik.WebControls; using Telerik;
public partial class Radstrip2 : System.Web.UI.Page { protected System.Web.UI.WebControls.Label PageContent; protected System.Web.UI.WebControls.Repeater BuildingSummary; protected Telerik.WebControls.PageView PageView1;
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
Tab tab = new Tab();
tab.Text = string.Format("New Page {0}", 1);
RadTabStrip1.Tabs.Add(tab);
PageView pageView = new PageView();
RadMultiPage1.PageViews.Add(pageView);
BuildPageViewContents(pageView, RadTabStrip1.Tabs.Count);
RadTabStrip1.SelectedIndex = 0;
}
}
private void BuildPageViewContents(PageView pageView, int index)
{
pageView.ID = "Page " + index.ToString();
pageView.Controls.Add(new LiteralControl(" <B>New page</B>" + (index).ToString()));
}
protected void Button1_Click(object sender, EventArgs e)
{
Tab tab = new Tab();
tab.Text = string.Format("New Page {0}", RadTabStrip1.Tabs.Count + 1);
RadTabStrip1.Tabs.Add(tab);
PageView pageView = new PageView();
pageView.ID = "Page " + pageView.Index.ToString();
RadMultiPage1.PageViews.Add(pageView);
BuildPageViewContents(pageView, RadTabStrip1.Tabs.Count);
RadTabStrip1.SelectedIndex = RadTabStrip1.SelectedIndex + 1;
RadMultiPage1.SelectedIndex = RadTabStrip1.SelectedIndex;
}
protected void Button2_Click(object sender, EventArgs e)
{
Tab currentTab = RadTabStrip1.InnerMostSelectedTab;
if (currentTab != null)
{
ITabContainer owner = currentTab.Owner;
owner.Tabs.Remove(currentTab);
//RadMultiPage1.PageViews.Remove(currentTab.PageView);
if (owner.Tabs.Count > 0)
{
owner.SelectedIndex = 0;
}
}
}
protected void RadMultiPage1_PageViewItemCreated1(PageView view, int viewIndex)
{
BuildPageViewContents(view, viewIndex + 1);
}
}
© Stack Overflow or respective owner