Hi
I have something like this
public class ViewModel
{
public List<Books> Test {get; set;}
public SelectList List {get; set;}
public ViewModel()
{
Test = new List<Books>();
}
}
public class Books
{
public string SelectedByUser {get; set;}
}
<% for (int i = 0; i < 1; i++)
{ %>
<%: Html.DropDownListFor(m => ViewModel.Books[i].SelectedByUser, SelectList);
<% } %
controller
ViewModel.Test.add(new Books() { SelectedByUser = 5});
html rendered
<select>
<option value="1">1</option>
<option value="5">5</option>
</select>
So it should put "5" as the selected option but it does not seem to bind it and make "5" the selected one.
If I "SelectedByuser" to the ViewModel then it will work but when it is in a list it does not.