I am working with an MVC4 application. I have created the model class and its child collections.
And since I am developing a strongly typed view using the .cshtml page which takes the parent model class as its model, in the .cshtml page, I don't know how can I access the attributes of the child collection. When I say something like,
@Html.TextBoxFor(model=>model.)
It lists only the parent's direct attributes and I don't know how to access the child collections attributes in this .cshtml page.
My model:
public partial class Parentmodel
{
public string FirstName;
public string LastName;
public ICollection<ChildEntity> ChildEntityObj { get; set; }
}
public class ChildEntity
{
public decimal PhoneNumber;
public string Addr1;
public string CountryNowLiving;
}
In the view, I am using the ParentModel. So, I am not able to access the PhoneNumber in my .cshtml file. Not only PhoneNumber, But I have many fields in the ChildEntityCollection. Only first name and last name comes up in the dropdown. I understand that I must use the foreach or for loop but I am not sure of how it should be proceeded.