This means that the object you want to save ( DataView ) is not marked SerializableAttribute .
Now, the reason you get this error with ViewState, and not with Session, is because the ViewState is always serialized, but this is not necessarily true for Session. In-process sessions are stored in server memory and do not require serialization. SQLServer sessions must be serialized for storage in the database.
So, anytime you want to save an object in a ViewState (or serialized session), it should be marked SerializableAttribute .
source share