これを試して:
コントローラ:
public class HomeController : Controller
{
public ActionResult Index()
{
var myViewModel = new MyViewModel()
{
Form = new MyFormViewModel {Name = "Header"},
FormViewModels = new List<MyFormViewModel>()
{
new MyFormViewModel() {Name = "First"},
new MyFormViewModel() {Name = "Secound"}
}
};
return View(model: myViewModel);
}
[HttpPost]
public ActionResult Index(FormCollection collection, List<MyFormViewModel> FormViewModels, MyViewModel myView)
{
return View();
}
}
モデル:
public class MyViewModel
{
public MyFormViewModel Form { get; set; }
public IList<MyFormViewModel> FormViewModels { get; set; }
}
public class MyFormViewModel
{
public string Name { get; set; }
}
意見:
@model MvcChat.Models.MyViewModel
@{
ViewBag.Title = "Home Page";
}
@using(Html.BeginForm())
{
@Html.EditorFor(model=>model.Form.Name)
for (int i = 0; i < Model.FormViewModels.Count; i++)
{
@Html.EditorFor(x => x.FormViewModels[i])
}
<input type="submit" value="go"/>
}
結果は次のようになります ( http://i.stack.imgur.com/t0Je0.png ):