我使用此代码在我的视图中显示下拉菜单列表,我想在List的开头添加一个STATIC值,文本为None,值为“”。如何在剃刀中做到这一点?
@Html.DropDownListFor(modal => modal.Candidates, new SelectList(Model.Candidates, "Value", "Key"))
答案 0 :(得分:3)
DropDownListFor
超载,default string,例如
@Html.DropDownListFor(modal => modal.Candidates,
new SelectList(Model.Candidates, "Value", "Key"),
"None")