我正在显示我的页面上的数据集合。我为每一行显示标签和文本框。MVC3:更新后的值不会反映在文本框后
下面是我查看示例代码:
@using (Html.BeginForm())
{
<input type="submit" value="Ok" />
@for (int index = 0; index < Model.Persons.Count; index++)
{
@Model.Persons[index].Name
@Html.TextBoxFor(m => Model.Persons[index].Amount)
}
}
在POST操作,我更新量(说5增加)。
[HttpPost]
public ActionResult Persons(PersonList presenter)
{
for (int index = 0; index < presenter.Persons.Count; index++)
{
presenter.Persons[index].Amount += 5;
}
return View(presenter);
}
此更新的金额未反映在页面上。 但是,如果我用下面的代码则正常显示,像
@Model.Persons[index].Amount
或者
<input type="text" [email protected]("Persons_" + index + "__Amount") name="Persons[@index].Amount " value="@Model.Persons[index].Amount" ></input>
我想这样的行为为什么会发生的原因是什么?
任何帮助,将不胜感激。