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
Guest UserPosted Nov 30, 2021, 6:24 AM
Jignesh KumarPosted Nov 30, 2021, 3:29 AM
Hi Shusant,
Please refer this article which will help you, refer this point "Populate a DropDownList using Viewbag"
https://www.c-sharpcorner.com/article/different-ways-bind-the-value-to-razor-dropdownlist-in-aspnet-mvc5/