【发布时间】:2012-10-20 17:47:04
【问题描述】:
我有绑定到视图的通用列表属性。问题是当我在视图中输入一些值后发布数据时,页面会刷新并且它不会保留视图中的值。而且当我尝试为该特定字段添加Html.ValidationMessage 时,我得到一个错误
"The value 'System.Collections.Generic.List`1[<name of the class>]' is invalid"
我的代码如下所示, 型号
public List<Chart> Charts
{
get
{
return _repository.GetCharts(Convert.ToInt32(this.Template_Id));
}
set{}
}
实际类
public class Chart
{
public string ChartDisplayText { get; set; }
}
Chart 类中的属性是我在 View 中输入值的属性 非常感谢任何帮助,谢谢
【问题讨论】:
-
不确定我是否理解正确,但看起来您的新值并未保存到您在 _repository.GetCharts 方法中加载数据的任何位置。
标签: asp.net-mvc list generics