2
Answers

bind ALL option in dropdownlist

Guest User

Guest User

3y
731
1

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)