This is a migrated thread and some comments may be shown as answers.

Issue with dynamically generated pageview

5 Answers 92 Views
TabStrip
This is a migrated thread and some comments may be shown as answers.
Babu Puchakayala
Top achievements
Rank 1
Babu Puchakayala asked on 24 May 2010, 08:05 PM

hi,

I have created a dynamic tab function. When i click button1 it will create dynamic tab and pageview for that tab. But when i deleted that tab that pageview is not deleting. Can any one help me to fix this

HERE IS MY SAMPLE CODE

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

5 Answers, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 26 May 2010, 03:39 PM
Hello Babu,

You should first remove the pageview and then the tab:

ITabContainer owner = currentTab.Owner;
RadMultiPage1.PageViews.Remove(currentTab.PageView);
owner.Tabs.Remove(currentTab);

All the best,
Yana
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
CWT
Top achievements
Rank 1
answered on 22 Oct 2010, 12:31 AM
Hi I am having the same issue, tried what Yana suggested but still doesnt work.
0
Yana
Telerik team
answered on 22 Oct 2010, 08:07 AM
Hello CWT,

We cannot help unless you send us some sample code.

Kind regards,
Yana
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
CWT
Top achievements
Rank 1
answered on 25 Oct 2010, 01:00 AM
HI, please see below closebtn coding:

 

protected void CloseTabbtn_Click(object sender, EventArgs e)

 

{

 

ImageButton b = sender as ImageButton;

 

 

string imgname = b.AlternateText.ToString();

 

 

 

RadTab currentTab = RadTabStrip1.FindTabByText(imgname);

 

 

int pageindex = currentTab.Owner.SelectedIndex;

 

 

IRadTabContainer owner = currentTab.Owner;

 

RadMultiPage1.PageViews.RemoveAt(currentTab.Owner.SelectedIndex);

 

owner.Tabs.Remove(currentTab);

 

if (owner.Tabs.Count > pageindex)

 

{

owner.SelectedIndex = pageindex;

 

}

 

else

 

{

owner.SelectedIndex = pageindex - 1;

 

 

}

RadTabStrip1.DataBind();

 

SessionUtility.SavePageObject(this, "RadTabStrip", RadTabStrip1.GetXml());

 

 

}

0
CWT
Top achievements
Rank 1
answered on 25 Oct 2010, 05:17 AM
HI,

its working fine. I missed the Ajax update. Thanks for your help.
Tags
TabStrip
Asked by
Babu Puchakayala
Top achievements
Rank 1
Answers by
Yana
Telerik team
CWT
Top achievements
Rank 1
Share this question
or