以下面的示例类。我想在表单上显示客户和两个地址(来自列表)。 MVC测试版中的模型联编程序是否支持这个功能,还是需要编写我自己的定制联编程序?ASP.NET MVC Beta支持列表中的模型绑定器<T>?
public class Customer
{
public string FirstName { get; set; }
public string LastName { get; set; }
public List<Address> Addresses { get; set; }
public Customer()
{
Addresses = new List<Address>();
}
}
public class Address
{
public int Line1 { get; set; }
public int Line2 { get; set; }
public int City { get; set; }
public int State { get; set; }
public int Zip { get; set; }
}
你会如何编码字段?喜欢这个?
<!-- some HTML formatting -->
<%= Html.TextBox("customer.address.line1", ViewData.Customer.Address[0].Line1)%>
<!-- some more HTML formatting -->
<%= Html.TextBox("customer.address.line1", ViewData.Customer.Address[1].Line1)%>
<!-- end of HTML form formatting -->
我想我会在不久的将来需要类似的东西,很好的问题。 – 2009-01-06 10:39:30