Hi, I've got the following in my view:
<%= Html.DropDownList("Schema.MetaData.SourceTableName", new SelectList(Model.Schema.MetaData.SourceTableNames, Model.Schema.MetaData.SourceTableName), Model.SourceTablesOptionLabel)%>
SourceTableNames is of type List<string>
When I populate the model, I assign the value for SourceTableName using the following method on my view model:
public void SetDefaultSourceTable(string mostLikelyCandidate)
{
Debug.Assert(this.Schema.MetaData.SourceTableNames.Contains(mostLikelyCandidate));
this.Schema.MetaData.SourceTableName = mostLikelyCandidate;
}
(the Debug.Assert
demonstrates that whatever I pass in is part of the SourceTableNames list)
Unfortunately, whatever I pass to that method, and even though all the properties are correct even when I put a breakpoint in the view itself, the first options is always selected
<SELECT id=Schema_MetaData_SourceTableName name=Schema.MetaData.SourceTableName>
<OPTION selected>Table A</OPTION>
<OPTION>Table B</OPTION>
<OPTION>Table C</OPTION>
</SELECT>
Any clue as to what I'm doing wrong?