我的操作方法(下面的代码)中生成了一个简单的选择列表
pDays.getPointer()
如何在其中添加一个占位符值作为默认值?
答案 0 :(得分:1)
以下是在您的SelectList / DropDownList中将占位符设置为默认值的解决方案:
在控制器方法中:
var espAdminList = db.esp_admin_form_demographics.Where(x => x.category == (int) SelectHelper.ClientSelectOptions.Demographics.BirthCountry || x.category == 999)
Viewbag.EspAdminSelectList = new SelectList(espAdminList, "id", "value");
然后在视图中:
@Html.DropDownList("EspAdminId",ViewBag.EspAdminSelectList as SelectList, "Select Esp. Admin", new { @class = "form-control" })