Unable to cast object of type 'Telerik.Web.UI.RadMultiPage' to type 'System.Web.UI.UserControl'.

2 posts, 0 answers
  1. doug thompson
    doug thompson avatar
    10 posts
    Member since:
    Mar 2006

    Posted 10 Jan 2012 Link to this post

    error: Unable to cast object of type 'Telerik.Web.UI.RadMultiPage' to type 'System.Web.UI.UserControl'.

    When going through a user control for a EditFormUserControl and I wanted to list all the user controls on that page but doing a foreach loop I need a fairly consistent type to iterate through.  So how can I iterate through 'userControl' when it could be a lteral for a label or  a 'RadMultiPage' or a 'UserControl'.  I have tried ...string objectTypeName="RadMultiPage";




    T = Type








    But I just wanter to be able to have a reursive call listing out all the children be them Usercontrol or Telerik User controls. 
    Any Ideas ?




    UserControl userControl = (UserControl)e.Item.FindControl(GridEditFormItem.EditFormUserControlID);



    (object uc in ((UserControl)userControl).Controls){}


  2. Kate
    Kate avatar
    1898 posts

    Posted 13 Jan 2012 Link to this post

    Hi Doug,

    Please refer to the following forum post that might give you a clearer understanding of how you can achieve the desired behavior:

    • http://forums.asp.net/t/1726687.aspx/1
    • http://stackoverflow.com/questions/3834544/loop-through-controls-of-a-usercontrol
    • http://stackoverflow.com/questions/2632302/loop-through-all-the-user-controls-on-a-page
    • http://aspmessageboard.com/showthread.php?t=161740

    Kind regards,
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Back to Top