本文介绍了如何使用属性列表类和属性列表类值保存在视图状态比错误System.Runtime.Serialization.Serializationexception的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用属性列表类和属性列表类值保存在视图状态而不是错误System.Runtime.Serialization.SerializationException

错误代码:---

how to i use a property list class and property list class value save in view state than error System.Runtime.Serialization.SerializationException
error code:---

List<ChildrenName> Childrenlist;
if (ViewState["ChildrenName"] != null)
    Childrenlist = (List<ChildrenName>)ViewState["ChildrenName"];
else
    Childrenlist = new List<ChildrenName>();
Childrenlist.Add(new ChildrenName() { Name = txtChildrenName.Text });
ViewState["ChildrenName"] = Childrenlist;
List<ChildrenName> obj = (List<ChildrenName>)ViewState["ChildrenName"];
repChildrenName.DataSource = Childrenlist;
repChildrenName.DataBind();







public class ChildrenName
   {
       public string Name { get; set; }
   }

推荐答案

[Seriaziable]
public class ChildrenName
{
   public string Name { get; set; }
}


这篇关于如何使用属性列表类和属性列表类值保存在视图状态比错误System.Runtime.Serialization.Serializationexception的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-11 15:42