Hello,
In my model, I have this :
public class CustomerModel
{
public Customer Customer { get; set; }
public Language Language { get; set; }
public IList<Language> Languages { get; set; }
public CustomerModel()
{
Language = new Language();
}
}
In my view, I have this :
<%: Html.DropDownList("Id", new SelectList(Model.Languages, "Id", "Code"))%>
that's work
But I'd like when I do a submit, have the Model.Language.Id setted to the value selected I tried this, but not work :
<%: Html.DropDownList(m => m.Language.Id, new SelectList(Model.Languages, "Id", "Code"))%>
Updat1: I used this solution, ok working
<%: Html.DropDownList("Language",
new SelectList(ViewData.Model.Languages, "Id", "Code")) %>
When I select a customer, I'd like see the language change depending customer language, I did this :
<%: Html.DropDownList("Language", new SelectList(ViewData.Model.Languages, "Id", "Code", ViewData.Model.Customer.Language.Id)) %>
nothing happen, I still see the first language of the list and not the customer language. The data in the controller are correct
Thanks,