bra*_*rad 3 asp.net-mvc asp.net-core
长时间中断后刚刚回到编码...我尝试使用 Html.GetEnumSelectList<> 显示枚举中的列表,但是 Visual Studio 2019 似乎无法识别(无智能感知)并且代码无法工作。
@using AspNetCoreVideo.Models
@model AspNetCoreVideo.Entities.Video
@addTagHelper *, Microsoft.aspnetcore.mvc.taghelpers
<h2>Create Vidio</h2>
<form asp-action="Create" method="post">
<table>
<tr>
<td><label asp-for="Title"></label></td>
<td><input asp-for="Title" /></td>
</tr>
<tr>
<td><label asp-for="Genre"></label></td>
< td><select asp-for="Genre" asp-items="Html.GetEnumSelectList<Genres>()"></select></td>
</tr>
</table>
<input type="submit" value="Create" />
</form>
Run Code Online (Sandbox Code Playgroud)
期望显示“流派”列表,但是列表中什么也没有。
小智 7
我也遇到了类似的问题,选择什么也没有显示。后来发现是因为使用了select标签的原因。如果你像这样将它用作单个元素,<select />它将无法工作。您必须使用它,<select></select>
希望这会对某人有所帮助。
| 归档时间: |
|
| 查看次数: |
2162 次 |
| 最近记录: |