@Html.DropDownListFor How to add option?

后端 未结 3 1265
[愿得一人]
[愿得一人] 2021-01-03 21:03
@Html.DropDownListFor(model => model.ZipFile, new SelectList(ViewBag.ZipFiles))

The above code creates me a select list just fine. But I want to

3条回答
  •  旧时难觅i
    2021-01-03 21:57

    By using the proper DropDownListFor overload:

    @Html.DropDownListFor(
        model => model.ZipFile, 
        new SelectList(ViewBag.ZipFiles),
        "-- please select a zip file --"
    )
    

提交回复
热议问题