2016-10-18 15 views
2

私はこのような私のページでビューステートを宣言した:Viewstateでテーブルのシリアル化を修正する方法は?

public class TMP_RequestCourse 
{ 
    public int CourseCode; 
    public string CourseTitle; 
    public int PriorityID; 
} 
public TMP_RequestCourse T_RequestCourse 
{ 
    get 
    { 
     if (ViewState["TMP_RequestCourse"] == null) 
      return new TMP_RequestCourse(); 
     return (TMP_RequestCourse)ViewState["insertMode"]; 
    } 
    set { ViewState["TMP_RequestCourse"] = value; } 
} 

が、ページがロードされたときに、私は次のエラーを受け取る:

Type 'App.UI.Pages.EduRequestEdit+TMP_RequestCourse' in Assembly 'App.UI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' is not marked as serializable.

答えて

1

あなたのクラスにSerializableAttributeを追加する必要があります。

[Serializable] 
public class TMP_RequestCourse 
{ 
    public int CourseCode; 
    public string CourseTitle; 
    public int PriorityID; 
} 

When you create an object in a .Net framework application, you don't need to think about how the data is stored in memory. Because .Net framework takes care of that for you. However, if you want to store the contents of an object to a file, send an object to another process or transmit it across the network, you do have to think about how the object is represented because you will need to convert it to a different format. This conversion is called SERIALIZATION.

Reference

関連する問題