简写用于决定在 razor Html.DropDownListFor() 的页面加载时选择哪个选项。您可以尝试运行以下代码片段 -
// return Boolean value @Html.DropDownListFor(m => m.Valeur, new List< SelectListItem > { //new list item list item1 is generated new SelectListItem { Value = "0" , Text = "Show", Selected = Model.Valeur == 0 }, new SelectListItem { Value = "1" , Text = "Hide", Selected = Model.Valeur != 0 }, }, new { @class = “selectnew" })
以上是在HTML中,将'Choose which option is selected on pageload of razor Html.DropDownListFor()'翻译成中文为'在Razor的Html.DropDownListFor()中,选择在页面加载时被选中的选项是哪个?'的详细内容。更多信息请关注PHP中文网其他相关文章!