簡寫用於決定在 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中文網其他相關文章!