LoadOnDemand ComboBox inside LoadOnDemand TabStrip Losing Viewstate

1 posts, 0 answers
  1. Ata Turkoglu
    Ata Turkoglu avatar
    1 posts
    Member since:
    Jul 2009

    Posted 16 Jul 2009 Link to this post

    1 // I used a short string array for my ascx page names:  
    2     string[] userControlNames = { "0 Index""FirstPage""SecondPage""ThirdPage" };  
    3  
    4     protected void Page_Load(object sender, EventArgs e)  
    5     {  
    6         if (!Page.IsPostBack)  
    7         {  
    8             AddTab("1st Tab""1");  
    9             AddPageView(RadTabStrip1.FindTabByText("1st Tab"));  
    10             AddTab("2nd Tab""2");  
    11             AddTab("3rd Tab""3");  
    12         }  
    13     }  
    14  
    15     private void AddTab(string tabName, string tabID)  
    16     {  
    17         RadTab tab = new RadTab();  
    18         tab.Text = tabName;  
    19         tab.AccessKey = tabID;  
    20         RadTabStrip1.Tabs.Add(tab);  
    21     }  
    22  
    23     private void AddPageView(RadTab tab)  
    24     {  
    25         RadPageView pageView = new RadPageView();  
    26         pageView.ID = tab.AccessKey;  
    27         RadMultiPage1.PageViews.Add(pageView);  
    28         pageView.CssClass = "pageView";  
    29         tab.PageViewID = pageView.ID;  
    30     }  
    31  
    32     protected void RadMultiPage1_PageViewCreated(object sender, RadMultiPageEventArgs e)  
    33     {  
    34         string userControlName = userControlNames[int.Parse(e.PageView.ID)].ToString() + "CS.ascx";  
    35  
    36         Control userControl = Page.LoadControl(userControlName);  
    37         userControl.ID = e.PageView.ID + "_userControl";  
    38  
    39         e.PageView.Controls.Add(userControl);  
    40     }  
    41  
    42     protected void RadTabStrip1_TabClick(object sender, RadTabStripEventArgs e)  
    43     {  
    44         AddPageView(e.Tab);  
    45         e.Tab.PageView.Selected = true;  
    46     }

    This is my codebehind file for my OnDemand loaded TabStrip. It's working fine.
    Inside the first tabbed PageView I also have several RadComboBoxes wich also have an OnDemand loading feature 
    (let's assume a Country--> City --> Region loader) like that one in your examples.

    When I load the page the first tab is shown and inside it the ComboBox bind to country data waits for me to select a Country.
    I select a country and the City Combobox is successfully ondemand bind to cities data and waits for me to select a city.
    I select the city and now the last Combobox is ondemand bind to Region data wich I can select finally. No problems here.

    Then, when I go to the second tab the loading panel is shown for a couple of seconds and the 2nd tab is shown. Still no problem.

    But when I go back to the first tab all my selections inside the ComboBoxes disappear. Even the loaded items inside are lost except the Country combo which was filled on PageLoad. Also the country is still selected inside this ComboBox.

    So I think when the RadMultiPage1_PageViewCreated event is fired the viewstate of my Comboboxes gets lost. You can see that my code is a little bit different than your example. The difference is that I set my ASCX page names from an array, but I keep in mind that giving unique ID's to PageView.Controls is important and I think my code does this exactly.

    So why I am still losing the viewstate of my ondemand loaded ComboBoxes? Can anyone help me out of this please?

    Many Thanks..
Back to Top