User Control - InvalidCastException: Specified cast is not valid

Discussion in 'ASP .Net Web Controls' started by Ajit, Apr 22, 2004.

  1. Ajit

    Ajit Guest

    Hi,

    My control works fine unless until i add dropdownlist box.
    When i add dropdownlist box to control and try to test that
    control in my aspx page it gives the following error.

    ===================================
    Specified cast is not valid.
    Description: An unhandled exception occurred during the execution of the
    current web request. Please review the stack trace for more information
    about the error and where it originated in the code.

    Exception Details: System.InvalidCastException: Specified cast is not valid.

    Source Error:

    An unhandled exception was generated during the execution of the
    current web request. Information regarding the origin and location of the
    exception can be identified using the exception stack trace below.

    Stack Trace:

    [InvalidCastException: Specified cast is not valid.]
    System.Web.UI.WebControls.ListControl.LoadViewState(Object savedState)
    +17
    System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +125
    System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +311
    System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +311
    System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +311
    System.Web.UI.Page.LoadPageViewState() +172
    System.Web.UI.Page.ProcessRequestMain() +421


    ===================================
    Any suggession will be of great help

    thanx in advance.
     
    Ajit, Apr 22, 2004
    #1
    1. Advertising

  2. Hi Ajit,

    It seems like the control tree is somewhat changing and the control is
    having trouble trying to reconstruct it. Could you post a very small sample
    to repro this issue? Also, at which point are you creating adding the child
    controls?

    --
    Victor Garcia Aprea
    Microsoft MVP | ASP.NET
    Looking for insights on ASP.NET? Read my blog:
    http://obies.com/vga/blog.aspx

    To contact me remove 'NOSPAM'. Please post all questions to the newsgroup
    "Ajit" <> wrote in message
    news:uUDWSv$...
    > Hi,
    >
    > My control works fine unless until i add dropdownlist box.
    > When i add dropdownlist box to control and try to test that
    > control in my aspx page it gives the following error.
    >
    > ===================================
    > Specified cast is not valid.
    > Description: An unhandled exception occurred during the execution of the
    > current web request. Please review the stack trace for more information
    > about the error and where it originated in the code.
    >
    > Exception Details: System.InvalidCastException: Specified cast is not

    valid.
    >
    > Source Error:
    >
    > An unhandled exception was generated during the execution of the
    > current web request. Information regarding the origin and location of the
    > exception can be identified using the exception stack trace below.
    >
    > Stack Trace:
    >
    > [InvalidCastException: Specified cast is not valid.]
    > System.Web.UI.WebControls.ListControl.LoadViewState(Object savedState)
    > +17
    > System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +125
    > System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +311
    > System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +311
    > System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +311
    > System.Web.UI.Page.LoadPageViewState() +172
    > System.Web.UI.Page.ProcessRequestMain() +421
    >
    >
    > ===================================
    > Any suggession will be of great help
    >
    > thanx in advance.
    >
    >
    >
    >
     
    Victor Garcia Aprea [MVP], Apr 24, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ajit
    Replies:
    1
    Views:
    3,621
    Victor Garcia Aprea [MVP]
    Apr 24, 2004
  2. Floela
    Replies:
    3
    Views:
    578
    Jon Skeet
    Jul 10, 2003
  3. Arjen
    Replies:
    1
    Views:
    7,774
    Carl Prothman [MVP]
    Aug 6, 2003
  4. Miguel Angel Dinelli
    Replies:
    1
    Views:
    448
    Chris Jackson
    Nov 13, 2003
  5. Ajit
    Replies:
    1
    Views:
    188
    Victor Garcia Aprea [MVP]
    Apr 24, 2004
Loading...

Share This Page