I want to make a model for mvc page like this:
public class Body
{
public int Id { get; set; }
public class Hand
{
public List<Fingers> fingers { get; set; }
}
public class Foot
{
public List<Toes> toes { get; set; }
}
public class Head
{
public Nose nose {get; set;}
public List<Ears> ears { get; set; }
public List<Eyes> eyes { get; set; }
}
}
Then have a class for Fingers like this:
public class Fingers
{
public int Id { get; set; }
public string Description { get; set; }
}
Then access it like this in my view:
@model Models.Body
@foreach (var fingers in Model.Hand.Fingers)
{
@Html.RadioButton("fingerList", fingers.Description)
}
Am I doing my model wrong? Right now VS doesn't recognize the Model.Hand
in the foreach
, much less the Model.Hand.Fingers
. I don't want to make the @model
IEnumerable
because this page should only show one person
, but it can have multiple lists of fingers
, toes
, etc.