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

On PageViewPage load; bind controls on page

1 Answer 107 Views
PageView
This is a migrated thread and some comments may be shown as answers.
Adrian
Top achievements
Rank 1
Adrian asked on 07 Jul 2011, 02:41 PM
I want to find a way to programatically detect if a PageViewPage has just loaded so that I could bind the controls that are on that page?
Method SelectedPageChanged works great when you click on the handle of a Page, but it is not what I am needing.

Just so you understand my situation; I have a top level RadPageView with many PageViewPages (Section A, Section B, Section C, Section D, Section E...etc...etc). Inside each one of the PageViewPages, I have another RadPageView control with many PageViewPages of its own (Section E - Page 1, Section E - Page 2). Please see attached screenshot for details.

For instance, when I click on one of the PageViewPages (Section E) of the top level RadPageView; I want to detect which PageViewPage of the lower level RadPageView control is visible and active, so that I can popluate all controls on that PageViewPage only, with values from the database.
How can this be accomplished?

1 Answer, 1 is accepted

Sort by
0
Boryana
Telerik team
answered on 13 Jul 2011, 10:05 AM
Hi Adrian,

Thank you for contacting us.

I tested your case using a RadPageView with two Pages. Each of the Pages contain one RadPageView instance with another two Pages. Each of the inner Pages contains two controls: either RadButtons or RadCheckBoxes.

The following code snippet illustrates how to reach the controls in the active Page of the nested RadPageViews, i.e. the RadButtons and the RadCheckBoxes:

public Form1()
{
    InitializeComponent();
    new RadControlSpyForm().Show();
    this.radPageView1.SelectedPageChanged += new EventHandler(radPageView1_SelectedPageChanged);
    this.radPageView2.SelectedPageChanged += new EventHandler(radPageView1_SelectedPageChanged);
    this.radPageView3.SelectedPageChanged += new EventHandler(radPageView1_SelectedPageChanged);
}
 
private void radPageView1_SelectedPageChanged(object sender, EventArgs e)
{
    RadPageViewPage selectedPage = radPageView1.SelectedPage;
 
    foreach (Control control in selectedPage.Controls)
    {
        RadPageView nestedPageView = control as RadPageView;
        if (nestedPageView != null)
        {
            RadPageViewPage selectedNestedPage = nestedPageView.SelectedPage;
            foreach (Control nestedControl in selectedNestedPage.Controls)
            {
                SetControlsText(nestedControl);
            }
        }
    }
}
 
private void SetControlsText(Control control)
{
    //implement your own logic here
    control.Text = "This Page is Active";
}

I hope you find this useful. Let me know whether the above suggestion helps.

Kind regards,
Boryana
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Tags
PageView
Asked by
Adrian
Top achievements
Rank 1
Answers by
Boryana
Telerik team
Share this question
or