View Single Post
  #2 (permalink)  
Old March 7th, 2010, 01:33 PM
Imar's Avatar
Imar Imar is offline
Wrox Author
Points: 72,022, Level: 100
Points: 72,022, Level: 100 Points: 72,022, Level: 100 Points: 72,022, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,076
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Hi Chcuk,

Yes, that's correct. ViewState stores Objects which enables you to store any type of object in it (as long as it can be serialized). When you store it, you know you store, say, a string. So the underlying object is really a string, but exposed as an object (as ViewState only understands objects). In order to get it back as the type you're expecting, you need to cast it.

Hope this helps,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
Reply With Quote