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

Dynamic Tabs, PageView and RadGrid

2 Answers 172 Views
TabStrip
This is a migrated thread and some comments may be shown as answers.
Officialboss
Top achievements
Rank 1
Officialboss asked on 30 Jun 2008, 11:53 PM
Hello,

Can someone please direct me to sample code where I can find examples of adding Dynamic Tabs, and for each of the Tab I want to a PageView and then Add a RadGrid to the PageView.

I have a Link List on the Page which onclick will create the Tab and content for the tab for each item in the List.

So far I am able to create the Tabs, I call the CreateTabContent Method below when an Item on the List is clicked.
    private void CreateTabContent(string Id) 
    { 
        bool tabExists = false
 
        for (int i = 0; i < RadTabStrip1.Tabs.Count; i++) 
        { 
            if (RadTabStrip1.Tabs[i].Text == "Plan Id " + id) 
            { 
                tabExists = true
                RadTabStrip1.SelectedIndex = i; 
                break
            } 
        } 
 
        if (tabExists) 
            return
 
        RadTab tab = new RadTab(); 
        RadTabStrip1.Tabs.Add(tab); 
        tab.Text = "Tab " + id; 
        AddPageView(id); 
    } 
     
    private void AddPageView(string pageViewID) 
    { 
        RadPageView pageView = new RadPageView(); 
        pageView.ID = "pv" +  pageViewID; 
        pageView.Controls.Add(CreateNewGrid(pageViewID)); 
        RadMultiPage1.PageViews.Add(pageView); 
    } 
     
    private RadGrid CreateNewGrid(string id) 
    { 
        RadGrid RadGrid1 = new RadGrid(); 
        RadGrid1.ID = "RadGrid1"
 
        SqlDataSource SqlDataSource1 = new SqlDataSource(); 
        SqlDataSource1.ConnectionString = ConfigurationManager.ConnectionStrings["MyConn"].ToString(); 
        SqlDataSource1.SelectCommandType = SqlDataSourceCommandType.StoredProcedure; 
        SqlDataSource1.SelectCommand = "MyData"
        DataSourceSelectArguments args = new DataSourceSelectArguments(); 
        SqlDataSource1.SelectParameters.Add("Id", id); 
        DataView view = (DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty); 
 
        DataTable table = view.ToTable(); 
 
        RadGrid1.DataSourceID = SqlDataSource1.ID; 
        RadGrid1.MasterTableView.DataKeyNames = new string[] { "ID" }; 
 
        RadGrid1.Width = Unit.Percentage(98); 
        RadGrid1.PageSize = 5; 
        RadGrid1.AllowPaging = false
        RadGrid1.PagerStyle.Mode = GridPagerMode.NextPrevAndNumeric; 
        RadGrid1.AutoGenerateColumns = true
        RadGrid1.ShowStatusBar = true
        RadGrid1.Skin = "Web20"
        RadGrid1.ShowStatusBar = true
 
        //Add Customers table 
        RadGrid1.MasterTableView.PageSize = 15; 
        RadGrid1.MasterTableView.Width = Unit.Percentage(100); 
 
        return RadGrid1; 
    } 


Thanks

2 Answers, 1 is accepted

Sort by
0
Officialboss
Top achievements
Rank 1
answered on 30 Jun 2008, 11:59 PM
After posting my above message;

I changed
RadGrid1.DataSourceID = SqlDataSource1.ID;
 

to
RadGrid1.DataSource = table


Now when I step through, I can see that the data is being assigned to the RadGrid but the Grid is not being added to the PageView OR I just can't see it.

I can see the Rad Grid if I add the RadGrid to PlaceHolder instead of the PageView.

Thanks
0
Atanas Korchev
Telerik team
answered on 01 Jul 2008, 05:44 AM
Hello Howard,

Please try setting the SelectedIndex property of your multipage. By default no pageview is selected (SelectedIndex = -1)

Regards,
Albert
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
TabStrip
Asked by
Officialboss
Top achievements
Rank 1
Answers by
Officialboss
Top achievements
Rank 1
Atanas Korchev
Telerik team
Share this question
or