Please see Darin's solution here .. Converting HTML.EditorFor into a drop down (html.dropdownfor?)
I am not able to make the drop down list work. Can any help with this please. Thank you.
I am getting BC30203 error in my ascx page.
BC30203: Identifier expected. (Line 4 - new[] ).. What do I put in place of model. I tried putting the actual model name and may be I am getting the syntax wrong.. this code goes in the editor template according to the posted solution link above...
Code:
<%= Html.DropDownList(
"",
new SelectList(
new[]
{
new { Value = "true", Text = "Yes" },
new { Value = "false", Text = "No" },
},
"Value",
"Text",
Model
)
) %>
No idea why you are getting such error, the code should work. The following editor template works perfectly fine for me, I have just tested it:
with the following model:
controller:
and view: