Data binding dynamically loaded user controls in a dynamically loaded RadPageView (FormView complications)

8 posts, 0 answers
  1. AdrianTaylor
    AdrianTaylor avatar
    10 posts
    Member since:
    Apr 2009

    Posted 20 Apr 2010 Link to this post

    A question on RabTabStrip, RadMultiPage, FormViews, two-way databinding, and dynamically loaded user controls:

    Has anyone put them all together sucessfully!?

    The closest Telerik demos I can find (such as TabStrip / Dynamic RadPageView) do the dynamic loading of user controls but they lack a formview and data binding features.

    I've almost got there.  At present I have managed to put together a FormView which includes several RadPageViews.  I have placed a user control inside each RadPageView declaratively.  This works great but when I try to add a RadPageView dynamically (inside Page_Load) and load the user control dynamically (PageViewCreated event) my data is no longer bound to the controls inside the loaded user control (no error).

    My FormView ID is FormView1 in the example below.  FormView1 is binding before before the PageView which I expect is the problem.
     
    How can I add the PageView before the FormView begins binding (assuming this is the problem)?

            protected void Page_Load(object sender, EventArgs e)  
            {  
                if (!IsPostBack)  
                {  
                    RadTab tab = new RadTab();  
                    tab.Text = "Tab1";  
                    TabStrip.Tabs.Add(tab);  
                    RadPageView pageView = new RadPageView();  
                    pageView.ID = "PageView1";  
                    //next line is triggering data binding which is perhaps too early? PageView has not been added yet  
                    RadMultiPage MultiPage1 = (RadMultiPage)FormView1.FindControl("MultiPage1");  
                    MultiPage1.PageViews.Add(pageView);  
                }  
            }  
     
            protected void RadMultiPage1_PageViewCreated(object sender, RadMultiPageEventArgs e)  
            {  
                string userControlName = e.PageView.ID + ".ascx";  
                Control userControl = Page.LoadControl(userControlName);  
                userControl.ID = e.PageView.ID + "Control";  
                e.PageView.Controls.Add(userControl);  
            }   
     

    More generally, in this scenario where I am trying to have one page, one formview, and one tabset with a different .ascx user control in each tab, is it advisable to instead use a different formview inside each control?  (These .ascx user controls are never re-used.)

    Thanks!
  2. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 23 Apr 2010 Link to this post

    Hi Adrian,

    Could you please send us the project with declaratively added pageviews, because I'm not sure I understand the exact scenario? Thanks in advance

    Kind regards,
    Yana
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. AdrianTaylor
    AdrianTaylor avatar
    10 posts
    Member since:
    Apr 2009

    Posted 23 Apr 2010 Link to this post

    Thanks Yana. 

    I have raised ticket ID 303507 with a project featuring two simple examples, one which works and one which does not.
  5. Craig Finnigan
    Craig Finnigan avatar
    14 posts
    Member since:
    May 2008

    Posted 18 Jul 2011 Link to this post

    Were you able to get a solution for this? I'm trying to do something very similar.
  6. Kate
    Admin
    Kate avatar
    1898 posts

    Posted 20 Jul 2011 Link to this post

    Hello Craig,

    Please find the attached project that implements the RabTabStrip, RadMultiPage, FormViews, two-way databinding, and dynamically loaded user controls in one place. 

    Kind regards,
    Kate
    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!

  7. John
    John avatar
    10 posts
    Member since:
    Jun 2010

    Posted 20 Dec 2011 Link to this post

    Kate

    Just wondering where in this sample two way databinding is implemented? I can see where the text box gets assigned a value but where does the datasource get bound back?

    Thanks
    John
  8. jumpstart
    jumpstart avatar
    479 posts
    Member since:
    Nov 2011

    Posted 22 Dec 2011 Link to this post

    John:

    It does not appear that the insert functionality has been implemented yet in this sample. Kate has provided the framework for being able to bind data to a RadTextBox implemented as a Control added to a RadPageView embedded in an ASP:FormView. You would need extend this to add update functionality.

    I found this YouTube walk-through helpful: ASP.NET Formview Control Access.

    Cheers!
  9. John
    John avatar
    10 posts
    Member since:
    Jun 2010

    Posted 27 Dec 2011 Link to this post

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