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!