微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

asp.net-mvc – ASP.NET MVC Beta支持列表中的Model Binder吗?

以下面的示例类为例.我想在表单上显示客户和两个地址(来自LIST). MVC beta中的模型绑定器是支持这个还是我必须编写自己的自定义绑定器?
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 -->

解决方法

我从来没有尝试过,但是看到 this帖子,它是关于模型绑定到列表,也许它可以帮助你.

原文地址:https://www.jb51.cc/aspnet/251212.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐