我想编辑我的模型限制的多个实例(例如4):
public int RestrictionID { get; set; }
public string portefeuille { get; set; }
我尝试这样做:
@model IEnumerable<Management.Models.Restriction>
@for ( int i= 0; i < 4; i++)
{
@Html.EditorFor(_ => Model.[i].portefeuille)
}
但是我有一个错误,我不能在IEnumerable类型上使用索引。
有人可以帮我解决这个问题吗?
尝试使用以下代码,ILIst
因为在IEnumerable
我们不能使用索引..对于使用索引,您应该使用IList
+删除多余的“。” 在Model
和之间[i]
:-
@model ILIst <Management.Models.Restriction>
@for ( int i= 0; i < 4; i++)
{
@Html.EditorFor(_ => Model[i].portefeuille)
}
欲了解更多信息,请看这里:-
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句