0
public class Poll
{
//...
public virtual ICollection<Answer> Answers { get; set; }
}
public class Answer
{
public int Id { get; set; }
[Required]
public string Content { get; set; }
private int _amount = 0;
public int Amount
{
get { return _amount; }
set { _amount = value; }
}
}
,我需要做一個編輯器查看。 如果我試試這個:
@foreach (var answer in Model.Answers)
{
@Html.EditorFor(model => answer)
}
這表明一切進行編輯,但犯規保存更改。控制器收到poll.Answers = null
你有沒有想出解決辦法?我有一個非常相似的情況。 – 2014-08-21 20:00:12
@JoFlash,我解決了這個像這樣someyhing:http://haacked.com/archive/2008/10/23/model-binding-to-a-list.aspx/ – Wonder 2014-08-22 08:53:25