Click here to Skip to main content
15,919,479 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello All,

I have implemented SQL Server session state in my application however I am
having some problems. Simple objects stored in Session state are fine and are
handled by .NET, however when I try to store gridview control in session state I am not able to figure out exactly what I have to
do to serialize and deserialize the object.

I am going thru below error

VB
Server Error in '/' Application.
Unable to serialize the session state. In 'StateServer' and 'SQLServer' mode, ASP.NET will serialize the session state objects, and as a result non-serializable objects or MarshalByRef objects are not permitted. The same restriction applies if similar serialization is done by the custom session state store in 'Custom' mode.
Posted

hi rohu123,
Gridview or most of the controls are not serializable. Class or object should have Serializable attribute in order to save or add it on the Session state.
 
Share this answer
 
You should not be storing UI controls in the session state. Instead, store the data which is being shown in that control (I guess that is either a DataTable or a List<YourModelObject>, both of which should be serialisable if you mark your object type as such).
 
Share this answer
 
Hello

Can you tell me why you need to save gridview into session? if I have any alternetive then let you know
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900