dropdownbox

@Html.DropDownListFor how to set default value [duplicate]

强颜欢笑 提交于 2019-11-26 17:42:39
This question already has an answer here: MVC5 - How to set “selectedValue” in DropDownListFor Html helper 3 answers @Html.DropDownListFor(model => model.Status, new List<SelectListItem> { new SelectListItem{Text="Active", Value="True"}, new SelectListItem{Text="Deactive", Value="False"}}) In view I am using this drop dowenlist coding. I run my application default deactive value is display in dropdown list box. I want display default Active Like this: @Html.DropDownListFor(model => model.Status, new List<SelectListItem> { new SelectListItem{Text="Active", Value="True"}, new SelectListItem{Text

@Html.DropDownListFor how to set default value [duplicate]

六月ゝ 毕业季﹏ 提交于 2019-11-26 04:47:17
问题 This question already has an answer here: MVC5 - How to set “selectedValue” in DropDownListFor Html helper 3 answers @Html.DropDownListFor(model => model.Status, new List<SelectListItem> { new SelectListItem{Text=\"Active\", Value=\"True\"}, new SelectListItem{Text=\"Deactive\", Value=\"False\"}}) In view I am using this drop dowenlist coding. I run my application default deactive value is display in dropdown list box. I want display default Active 回答1: Like this: @Html.DropDownListFor(model