2016-03-10 78 views
1
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

+0

控制器是什麼樣的? – christiandev

+0

'State'是一個複雜的對象,'