Sushant Torankar

Sushant Torankar

  • 1.5k
  • 505
  • 19k

bind ALL option in dropdownlist

Nov 29 2021 10:58 PM


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)