how to reach items in pageview which adds to multipage dynamicly?

2 posts, 0 answers
  1. Baris
    Baris avatar
    34 posts
    Member since:
    Jul 2013

    Posted 06 Feb 2014 Link to this post

    I'am using radMultipage. If I add the radpageviews at aspx like that
          

      

            <telerik:RadMultiPage ID="RadMultiPage1" Runat="server" OnPageViewCreated="RadMultiPage1_PageViewCreated">
                        <telerik:RadPageView ID="RadPageView1" runat="server" Height="159px" Width="163px">
                            <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
                            <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click"/>
                        </telerik:RadPageView>
            
                        <telerik:RadPageView
        
         ID="RadPageView2" runat="server" Height="159px" Width="163px">
                        <asp:Label ID="Label2" runat="server" Text="Label">
                        </asp:Label>
                        <asp:Button ID="Button2" runat="server" Text="Button" OnClick="Button2_Click" />
                    </telerik:RadPageView>
                </telerik:RadMultiPage>

    at code behind I use that 

        Label2.Text = "asdasdasas";


    but it if I add the radpageviews at runtime like that

                Telerik.Web.UI.RadPageView dataSelectionPV = new Telerik.Web.UI.RadPageView();
                dataSelectionPV.ID = "dataSelectionPV";
                System.Web.UI.Control ctrl = Page.LoadControl("DevelopmentSample.ascx");
                dataSelectionPV.Controls.Add(ctrl);

                Telerik.Web.UI.RadPageView outOfTimeSamplePV = new Telerik.Web.UI.RadPageView();
                outOfTimeSamplePV.ID = "outOfTimeSamplePV";
                System.Web.UI.Control ctrl2 = Page.LoadControl("OutOfTimeSample.ascx");
                dataSelectionPV.Controls.Add(ctrl2);

    I cant reach label2 at runtime at code behind. So ı cant write 

    Label2.Text = "asdasdasas";


    at runtime how can I reach items in pageview which adds to multipage dynamicly?
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 07 Feb 2014 in reply to Baris Link to this post

    Hi Baris,

    Please try the following C# code snippet to achieve your scenario.

    C#:
    RadPageView dataSelectionPV = new RadPageView();
    dataSelectionPV.ID = "PageView1";
    Control mynewcontrol = new Control();
    //access usercontrol page
    mynewcontrol = LoadControl("DevelopmentSample.ascx");
    //access label in usercontrol page
    Label label1 = (Label)mynewcontrol.FindControl("Label1");
    label1.Text = "Updated";
    dataSelectionPV.Selected = true;
    //adding usercontrol to pageview
    dataSelectionPV.Controls.Add(mynewcontrol);
    //adding pageview to multipage
    RadMultiPage1.PageViews.Add(dataSelectionPV);

    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top