【发布时间】:2017-10-06 13:02:41
【问题描述】:
我有以下代码生成带有值的下拉列表:
@Html.DropDownListFor(m => Model.BeslutsinformationstypId, VardemangderHelper.BeslutsInformationsTyperForInteckningarGetList(), new { @class = "form-control")})
现在我想默认选择一个选项。我尝试了以下方法:
@Html.DropDownListFor(m => Model.BeslutsinformationstypId, VardemangderHelper.BeslutsInformationsTyperForInteckningarGetList(), new { @class = "form-control", Selected = VardemangderHelper.BeslutsInformationsTyperForInteckningarGetList().First(x => x.Value == "320").Selected = true})
但这不起作用。如何根据VardemangderHelper.BeslutsiinformationsTyperForInteckningarGetList() 中的值设置所选选项?
是否可以在 Razor 中执行此操作?
【问题讨论】:
标签: c# asp.net-mvc razor