- -編集 - -
私はこのモデルを持っています
public class MainModel {
string Name;
List<Address> Addresses;
}
public class Address {
string prop2;
}
ビューを作成するのは非常に簡単ですが、POST リクエストでそれをバインドする方法が見つかりませんでした。Request.Form でのループを避けたい
意見
@foreach (var obj in Model.Address)
{
<tr>
<td>
<input type="text" id="@string.Format("obj.Name.{0}", obj.Id)" name="@string.Format("obj.Name.{0}", obj.Id)" value="@Model.Name" />
//I'm not able to overwrite the name attribute, still working on that
</td>
</tr>
}
このリストを ActionController に自動的にバインドする方法はありますか? 何かのようなもの
public ActionResult Edit(MainModel model, List<Address> objects)
カスタム モデル バインディングを作成する必要があると思いますが、その方法がわかりません。
... MVC は私たちを怠惰にします ... :)