私はクラスの連絡先を持っています:
public class Contact
{
public int Id { get;set; }
public Boolean DefaultYN {get;set; }
public string AdrType { get; set; }
public string Street {get; set; }
public string Town {get; set; }
public string HouseNr { get; set; }
public string PostCd { get; set; }
}
私はVieModelを持っています
public class ContactVm
{
public Contact SelectedContact { get; set; }
public Contact SelectedInvoiceContact { get;set; }
public List<Contact> ContactList { get; set; }
}
私は強く型付けされたビューを持っています
@model MvcBeaWeb.Models.ContactVm
<!-- Address Div -->
@using (Html.BeginForm("Index", "OrderSummary"))
{
<div id="deliveryAddressTab" class="deliveryAddressTab" style="margin: 10px 3px;">
@foreach (var item in Model.ContactList)
{
<div style="display: inline-block; float: left;">
@Html.RadioButtonFor(x => x.SelectedContact, item, new {@checked = true ,id = "item" + item.Id })
</div>
<div id="@item.Id" style="float: left; margin-left: 10px; font-weight: 500;">
<span class="spnTown">@item.PostCd @item.Town</span>
</div>
}
</div>
}
したがってContact
、ContactListのそれぞれSelectedContact
について、モデルのプロパティのラジオボタンを 1 つ作成することがわかります。しかし、これは複雑なタイプ (Contact オブジェクト) であるため、入力ボタンをクリックすると、OrderSummary コントローラーのインデックス アクションに移動します。
public ActionResult Index (ContactVm contactVm)
{
/* .... */
}
contactVm パラメータが空で、モデル バインディングが機能していないようです