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; }
}
@Html.DropDownListFor(m => m.JobSeeker.CurrentAddress.State,
new SelectList(Model.AllStates, "Id", "Name"), " -----Select List----- ")
結果是下拉填充有在AllStates,存在的值,但問題是m.JobSeeker.CurrentAddress。發佈到控制器操作時,State爲null。如何下拉列表中選擇的值設置爲財產m.JobSeeker.CurrentAddress.State
控制器是什麼樣的? – christiandev
'State'是一個複雜的對象,'