だから私は次のコードを持っています:
@model Project.Models.ViewModels.SomeViewModel
@using (Html.BeginForm("SomeAction", "SomeController", new { id = Model.Id}))
{
for(int i = 0; i < Model.SomeCollection.Count(); i++)
{
@Html.HiddenFor(x => Model.SomeCollection.ElementAt(i).Id)
<div class="grid_6">
@Html.TextAreaFor(x => Model.SomeCollection.ElementAt(i).Text, new { @style = "height:150px", @class = "grid_6 input" })
</div>
}
<div class="grid_6 alpha omega">
<input type="submit" value="Next" class="grid_6 alpha omega button drop_4 gravity_5" />
</div>
}
コントローラー側には次のものがあります。
[HttpPost]
public ActionResult SomeAction(int id, SomeViewModel model)
{
return PartialView("_SomeOtherView", new SomeOtherViewModel(id));
}
私のビューモデルは次のように設定されています。
public class SomeViewModel
{
public SomeViewModel()
{
}
public IEnumerable<ItemViewModel> SomeCollection { get; set; }
}
public class ItemViewModel{
public ItemViewModel(){}
public int Id {get;set;}
public string Text{get;set;}
}
SomeActionを実行すると、SomeCollectionは常に空になります。更新された値をユーザーに表示するにはどうすればよいですか。テキストプロパティとIDフィールド。