我有一个类:asp.net - MVC模型绑定到嵌套集合
public class ClientInformation{
public string UserName {get; set;}
public ICollection<RegionDistrictCity> RegionDistrictCity
{
get;
set;
}
public class RegionDistrictCity
{
public string Region { get; set; }
public string District { get; set; }
public string City { get; set; }
}
}
应该如何格式化的HTML输入元素的属性区域,Distirct,市的name属性,以使模型绑定填充集合“ICollection RegionDistrictCity”?
我试图使用类型为“ClientInformation”的参数的操作方法和像“[index] .PropertyName”格式化的html名称属性,但是在这种情况下只绑定了属性“UserName”。
我试图使用参数名称为“client”的操作方法,并具有像“client [index] .PropertyName”格式化的html名称属性,但它不起作用。 (在这种情况下,如果我有一个“列表客户端”,那么它会得到填充)
谢谢。
这是解决方案。实际上,我需要在jQuery中创建“名称”属性,但模型绑定所需的架构与上面报告的相同。 – Christian
我想你打算在你的'EditorFor'调用中使用变量'i'。 –