asp.net mvc How to add placeholder for html.dropdownlist

后端 未结 10 633
眼角桃花
眼角桃花 2021-01-01 23:13

I\'m using asp.net mvc 3.

I have this dropdownlist of countries and I want to add a placeholder for it. Here\'s my code:

@Html.DropDownList(\"country         


        
10条回答
  •  臣服心动
    2021-01-01 23:53

    Try this

    @Html.DropDownListFor(m => m.SelectedProductIDs, Model.AvaliableProducts.ToSelectList("ID","Name"), new { @class = "chzn-select", data-placeholder="Please select a product" })
    

    Or

    @Html.DropDownListFor(model => model.SelectedItemID, new SelectList(Model.employeeList, "Value", "Text"), new Dictionary { { "data-placeholder", "Choose a sandbox..." }, { "class", "chzn-select" }, { "style", "width:200px;" } })
    

提交回复
热议问题