在asp.net的MVC,你可以使用:设置默认/空值与选择TagHelper
@Html.DropDownListFor(model => model.Category, ViewBag.Category as IEnumerable<SelectListItem>, "-- SELECT --", new { @class = "form-control" })
使用asp.net 5,我怎么包括默认或空值( - 选择 - )在taghelper:
<select asp-for="Category" asp-items="@ViewBag.Category" class="form-control"></select>
那么简单,一旦你知道如何感谢马特。 – Reafidy
谢谢,这对我有帮助! –
我需要将该选项的值设置为空字符串,以允许用户将基础空值int字段清空: – DeveloperDan