开发者

dynamically generated pageview issue

开发者 https://www.devze.com 2022-12-31 16:51 出处:网络
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.

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);
}

}


I see that in your Button2_Click() method you remove the currently selected tab but you don't remove the current page view. You can try with:

    RadMultiPage1.PageViews.RemoveAt(RadMultiPage1.SelectedIndex);

This should remove the currently selected page view

0

精彩评论

暂无评论...
验证码 换一张
取 消