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

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

7 Answers 277 Views
TabStrip
This is a migrated thread and some comments may be shown as answers.
AdrianTaylor
Top achievements
Rank 1
AdrianTaylor asked on 20 Apr 2010, 05:38 PM

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!

7 Answers, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 23 Apr 2010, 03:15 PM
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.
0
AdrianTaylor
Top achievements
Rank 1
answered on 23 Apr 2010, 06:25 PM
Thanks Yana. 

I have raised ticket ID 303507 with a project featuring two simple examples, one which works and one which does not.
0
Craig Finnigan
Top achievements
Rank 1
answered on 18 Jul 2011, 06:33 PM
Were you able to get a solution for this? I'm trying to do something very similar.
0
Kate
Telerik team
answered on 20 Jul 2011, 08:48 AM
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!

0
John
Top achievements
Rank 1
answered on 21 Dec 2011, 03:48 AM
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
0
Richard
Top achievements
Rank 1
answered on 22 Dec 2011, 05:11 PM
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!
0
John
Top achievements
Rank 1
answered on 27 Dec 2011, 08:49 PM
Thanks
Tags
TabStrip
Asked by
AdrianTaylor
Top achievements
Rank 1
Answers by
Yana
Telerik team
AdrianTaylor
Top achievements
Rank 1
Craig Finnigan
Top achievements
Rank 1
Kate
Telerik team
John
Top achievements
Rank 1
Richard
Top achievements
Rank 1
Share this question
or