I have a DropDownlist that prompts a user for the State, when the user selects a state, ie. Colorado, it saves 'CO' in the database, works great. When the user goes back to the page, it shows 'CO' in the dropdown, but when the page posts back, the dropdownlist value is null. If I manually select a State again, posts back with the correct info and saves properly.
I'm creating the dropdownlist this way:
<%= Html.DropDownList(dropDownName, Model.StateProvinceSelectList, qa.AnswerValue)%>
Am I using the 3rd parameter correctly? qa.AnswerValue is the value from the database (contains "CO" in the example above).
Any help with this would be appreciated.
Here is my controller:
public ActionResult Proceed(List<QuestionAnswer> questionAnswers)
{
questionAnswer[x].AnswerValue // <--- This is blank on postback, but if user selects, it is set properly
...
}
and here is the html once the value has been set it looks like MVC engine sets the display, but not the value (in this case it is CO):
<select id="questionAnswers_5__AnswerValue" name="questionAnswers[5].AnswerValue">
<option value="">CO</option>
<option value="AL">ALABAMA</option>
<option value="AK">ALASKA</option>
<option value="AS">AMERICAN SAMOA</option>
<option value="AZ">ARIZONA </option>
...
</select>