Guest User

Guest User

  • Tech Writer
  • 515
  • 42.5k

bind ALL option in dropdownlist

Nov 29 2021 10:58 PM

hello,

I want to add ALL option in by dropdownlist code. Following is the code I am using to bind dropdown using Viewbag in mvc &  dropdown data is coming from database

 @Html.DropDownListFor(Model => Model.UserId, new SelectList(ViewBag.UserList, "Id", "Name", 0), "--Select Type--",  new { @class = "form-control", @id = "ddlUser" })

i want first option should be ALL , so If user selects ALL option, I can save  value 0 in database

thank you


Answers (2)