小编Ken*_*ins的帖子

ASP.NET MVC 3如何在Create视图上为具有ICollection属性的Model提供多字段创建功能

注意:我使用的是MVC3 + Razor,EF4,CF-CTP5

  1. 如何让视图能够在客户端上动态地为每个组织添加多个Address类,并在post上强烈绑定到模型?

  2. 如果(ModelState.IsValid == false),如果输入3个地址并发布无效模型,如何重新填充数字地址及其适当的值,如何在模型中使用视图解析值?

这是我的模特:

public class Organization
{
    public int Id { get; set; }
    public string Name { get; set; }
    public virtual ICollection<Address> Addresses { get; set; }
    public virtual ICollection<PhoneNumber> PhoneNumbers { get; set; }
    ...
}

public class Address
{
    public int Id { get; set; }
    public string Line1 { get; set; }
    public string Line2 { get; set; }
    public string City { get; set; }
    public string State …
Run Code Online (Sandbox Code Playgroud)

entity-framework-4 ef-code-first asp.net-mvc-3

5
推荐指数
1
解决办法
1597
查看次数