I create a selectList in my controller, to display in the view.
I'm trying to create it on the fly, sorta thing .. like this...
myViewData.PageOptionsDropDown =
new SelectList(new [] {"10", "15", "25", "50", "100", "1000"}, "15");
It compiles, but the output is bad...
<select id="PageOptionsDropDown" name="PageOptionsDropDown">
<option>10</option>
<option>15</option>
<option>25</option>
<option>50</option>
<option>100</option>
<option>1000</option>
</select>
Notice how no item is selected?
How can I fix this??
This is how I do it
At second glance I'm not sure I know what you are after...
Using the constructor that accepts
items, dataValueField, dataTextField, selectedValue
as parameters :Then in your view :
Using your example this worked for me:
controller:
view:
I just ran it like this and had no problems,
and
it also worked if you do this,
and
It may be the case that you have some ambiguity in your ViewData:
Take a look Here