User Control - InvalidCastException: Specified cast is not valid

A

Ajit

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.
 
V

Victor Garcia Aprea [MVP]

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,734
Messages
2,569,441
Members
44,832
Latest member
GlennSmall

Latest Threads

Top