Serialize Business Objects

Source: Internet
Author: User

Call ~ Finally, the paging control is ready. I'm so happy to use it in a previous system.
This system is developed based on Castle's ar.
Because my paging control needs to save the datasource of the control to viewstate, and the domain object I wrote cannot be serialized, the error is as follows:
Type *** must be marked as serializable or typeconverter other than referenceconverter to be placed in view State.
I found some information online.ArticleAfter you try again and make improvements, you can solve the problem by doing the following in the business object:

1. Add namespace:
Using system. runtime. serialization;
2. Add [serializable] before the class name
3. Let the class inherit iserializable
4. Add constructor to the class:
Protected users (serializationinfo info, streamingcontext context)
{
Id = info. getstring ("ID ");
Name = info. getstring ("name ");
Createdate = info. getdatetime ("createdate ");
}
5. Implement iserializable:
Public void getobjectdata (system. runtime. serialization. serializationinfo info,

System. runtime. serialization. streamingcontext context)
{

info. addvalue ("ID", ID);
info. addvalue ("name", name);
info. addvalue ("createdate", createdate);
}< br> what are these IDs, names, and createdate? It is a property of the users class.
OK. The problem is resolved successfully.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.