Fill Customize Drop down List in MVC

If you are using MVC Model to bind data, but you want to customize fill drop down. Use the below example
===============================
@Html.DropDownListFor(x => x.PV, new List<SelectListItem>
{
      new SelectListItem() {Text = "10", Value="10"},
      new SelectListItem() {Text = "20", Value="20"},
}, new { @class = "form-control", })

===============================

Comments

Popular posts from this blog

Tree view in winforms using c#

how to Replace null value with 0 Using C#

how to fetch all HTML Table Records and modify all records accordingly using jquery and Javascript