@Html.DropDownListFor(model => model.ZipFile,new SelectList(ViewBag.ZipFiles))
上面的代码创建一个选择列表就好了.但我想让选择是可选的.不幸的是没有空的选项,我想添加一个.我该怎么做?
解决方法
通过使用
proper DropDownListFor overload:
@Html.DropDownListFor( model => model.ZipFile,new SelectList(ViewBag.ZipFiles),"-- please select a zip file --" )