asp.net - MVC model binding to nested collection
I have a class:
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; }
}
}
How should be formated the name attribute of input elements for properties
Region, Distirct, City in html in order to make model binder populate
collection "ICollection RegionDistrictCity"?
I tried to have an action method with parameter of type
"ClientInformation" and html name attributes formated like
"[index].PropertyName" but in that case only the property "UserName" is
binded.
I tried to have action method with parameter name "client" and have html
names attributes formated like "client[index].PropertyName" but it doesn't
work. (in tha case if I there is a "List client" then it would get
populated)
Thanks.
No comments:
Post a Comment