<div class="editor-label"> @Html.LabelFor(model => model.Category) </div> <div class="editor-field"> @Html.EditorFor(model => model.Category) @Html.ValidationMessageFor(model => model.Category) </div>
这给了我一个标签和一个文本框.如何获取带有静态选择项的下拉列表来代替文本框.请帮忙.我是ASP.NET MVC的新手.我需要Razor语法的解决方案/建议.
解决方法
@Html.DropDownListFor( model => model.Category,new SelectList(new [] {"cat1","cat2","cat3"}) );