views:

201

answers:

1

when add dynamic control in update panel then getting failed to load viewsate error ?

see following example :-

UpdatePanel panel = new UpdatePanel();

panel.ContentTemplateContainer.Controls.Clear(); if (strPopupType == "O") { Control ctrl = Page.LoadControl(@"~/Modules/MLM/UnilevelViewer/DesktopModules/OrderDetails.ascx");

            OrderDetails orderdetails = (OrderDetails)ctrl;
            orderdetails.ID = "Orders" + elementID;
            orderdetails.OrderID = Convert.ToInt32(elementID);
            //orderdetails.ModuleSkinStyleName = CurrentModuleSkin;
            panel.ContentTemplateContainer.Controls.Add(ctrl);
        }
        else if (strPopupType == "U")
        {
            Control ctrl = Page.LoadControl(@"~/Modules/MLM/UnilevelViewer/DesktopModules/UserDetails.ascx");

            UserDetails userdetails = (UserDetails)ctrl;
            userdetails.ID = "Users" + elementID;
            // userdetails.UserModuleSkinStyleName = CurrentModuleSkin;
            userdetails.UserID = new Guid(elementID);

            panel.ContentTemplateContainer.Controls.Add(ctrl);
        }
A: 

Hai Tushar, Have a look at this Viewstate of a dynamically generated control

Pandiya Chendur