2010-05-24 49 views
1

我已經創建了動態的標籤功能。當我創建動態選項卡時,它將爲該選項卡創建瀏覽量。但是,當我刪除該選項卡的瀏覽量不會刪除。任何人都可以幫我解決這個問題。動態生成的網頁瀏覽問題

using System; 

using System.Data; using System.Configuration;使用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;使用Telerik.WebControls的 ;使用Telerik的 ;

public partial class Radstrip2:System.Web.UI.Page { protected System.Web.UI.WebControls.Label PageContent; 受保護的System.Web.UI.WebControls.Repeater BuildingSummary; 保護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); 
} 

}

回答

1

我看到在您的Button2_Click()方法刪除當前選中的選項卡,但不刪除當前頁面視圖。你可以嘗試:

RadMultiPage1.PageViews.RemoveAt(RadMultiPage1.SelectedIndex); 

這應該刪除當前選中的頁面視圖

+0

我得到它感謝您的幫助。 – Philly 2010-05-25 17:31:23