I currently have scaffolded a view where a boolean property of my model gets passed to the Html.EditorFor helper:
@Html.EditorFor(model => model.EndCurrentDeal)
All well and good, but what I'm really looking to do is massage that into a dropdown like:
<select> <option value="true" selected="selected">Yes</option> <option value="false">No</option> </select>
What's the easiest way to achieve that?
Thanks,
Chris
You can try something like here:
<%= Html.DropDownList( "", new SelectList( new[] { new { Value = "true", Text = "Yes" }, new { Value = "false", Text = "No" }, }, "Value", "Text", Model ) ) %>
If you want a default Value :
<%= Html.DropDownList( "", new SelectList( new[] { new { Value = "", Text = "None" }, new { Value = "true", Text = "Yes" }, new { Value = "false", Text = "No" }, }, "Value", "Text", Model ) ) %>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With