public class State
{
public Guid Id { get; set; }
public string Name { get; set; }
}
public class Address
{
public State State { get; set; }
}
public class JobSeeker
{
public Address CurrentAddress { get; set; }
}
public class RegisterVM
{
public JobSeeker JobSeeker { get; set; }
public List<State> AllStates { get; set; }
}
in Razor
@Html.DropDownListFor(m => m.JobSeeker.CurrentAddress.State,
new SelectList(Model.AllStates, "Id", "Name" ), " -----Select List----- ")
The result is the drop down is populated with the value present in AllStates, but the problem is m.JobSeeker.CurrentAddress.State is null when posted to controller action. How to set the selected value of dropdown to property m.JobSeeker.CurrentAddress.State