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

Adding tabs and pageviews in codebehind

4 Answers 186 Views
TabStrip
This is a migrated thread and some comments may be shown as answers.
Jason
Top achievements
Rank 2
Jason asked on 15 Jun 2008, 04:54 AM
I'm stumbling once again. This time, I'm trying to dynamically add tabs and an associated pageview to when an item from a RadGrid is selected.

The tab is created and selected, however the text does not get set, nor does it appear that the pageview is created. I've verified with a radalert that the e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["queueid"].ToString() does return a valid string.

What am I missing here?

protected void QueueGrid_ItemCommand(object source, GridCommandEventArgs e) 
    if (e.CommandName == "RowClick" && e.Item is GridDataItem) 
    { 
        if (RadTabStrip1.FindTabByText(e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["queueid"].ToString()) == null) 
        { 
            RadTab tab1 = new RadTab(); 
            RadTabStrip1.Tabs.Add(tab1); 
 
            RadPageView newpage = new RadPageView(); 
            RadMultiPage1.PageViews.Add(newpage); 
            newpage.ID = e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["queueid"].ToString(); 
            tab1.Text = e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["queueid"].ToString(); 
            tab1.Value = e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["queueid"].ToString(); 
            tab1.PageViewID = newpage.ID; 
            RadTabStrip1.SelectedIndex = RadTabStrip1.SelectedIndex + 1; 
            RadMultiPage1.SelectedIndex = RadMultiPage1.SelectedIndex + 1; 
        } 
    } 


4 Answers, 1 is accepted

Sort by
0
Jason
Top achievements
Rank 2
answered on 16 Jun 2008, 11:19 PM
Turns out to be an issue with having a TabTemplate. If I remove the following, I can create tabs and pageviews dynamically. Once I add it back, it creates blank tabs.

<TabTemplate> 
    <%# DataBinder.Eval(Container, "Text") %> 
    <img style="margin-left: 10px" src="/images/delete.gif" alt="Delete tab" onclick="deleteTab('<%# DataBinder.Eval(Container, "Text") %>')" /> 
</TabTemplate> 

0
Accepted
Erjan Gavalji
Telerik team
answered on 17 Jun 2008, 12:30 PM
Hi Jason,

To have the text evaluated, you should call the DataBind() method of the RadTabStrip, e.g. RadTabStrip1.DataBind();

Kind regards,
Erjan Gavalji
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Peter
Top achievements
Rank 1
answered on 23 Jul 2008, 02:25 AM
Hey, I have a question on this, how do I create the pageviews on runtime?  I am trying to do the same thing but I can't seem to find a way to generate a new pageview on runtime.
0
Paul
Telerik team
answered on 28 Jul 2008, 11:14 AM
Hello Peter,

Please take a look at our Dynamic RadPageView online example for details on the matter.

All the best,
Paul
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
TabStrip
Asked by
Jason
Top achievements
Rank 2
Answers by
Jason
Top achievements
Rank 2
Erjan Gavalji
Telerik team
Peter
Top achievements
Rank 1
Paul
Telerik team
Share this question
or