Dynamic Tabs, PageView and RadGrid

3 posts, 0 answers
  1. Officialboss
    Officialboss avatar
    43 posts
    Member since:
    Jan 2008

    Posted 30 Jun 2008 Link to this post

    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. Officialboss
    Officialboss avatar
    43 posts
    Member since:
    Jan 2008

    Posted 30 Jun 2008 Link to this post

    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
  3. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 01 Jul 2008 Link to this post

    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
Back to Top