我的模式是:如何實現模型的複雜類型
public class ContactInfo
{
public IEnumerable<SupplierContact> PriceRequest { get; set; }
public IEnumerable<SupplierContact> OrderConfirmation { get; set; }
public IEnumerable<SupplierContact> Account { get; set; }
}
public class SupplierContact
{
public int Id { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string Title { get; set; }
public string Email { get; set; }
public string MobilePhone { get; set; }
}
和我的控制器動作
public ActionResult EditContactInfo(ContactInfo contactInfo)
{
// not getting any values here..
}
查看被渲染,如:
@foreach (SupplierContact PriceRequest in Model.PriceRequest)
{
<tr class="">
<td style="text-align: left;" class="csstd-left">@Html.TextBoxFor(m => PriceRequest.Email)</td>
<td class="csstd">@Html.TextBoxFor(m => PriceRequest.MobilePhone)</td>
<td class="csstd">@PriceRequest.Title</td>
<td class="csstd">@PriceRequest.FirstName</td>
<td class="csstd">@PriceRequest.LastName</td>
</tr>
}
而且我引用@model ContactInfo
在我看來
但是我可以實現它使用
Request.Form.Get("PriceRequest.Email")
但我想要使用模型綁定功能。
謝謝。我錯過了MVC呈現控件的方式。 – 2014-09-01 12:03:58