How to bind the Dropdown list with hard code values in MVC?

In my previous blogs, we explored about MVC. You may please refer to the article.
In this blog, we will see how to bind a dropdown list with hard code values in MVC.

Bind Static values with a Dropdown list in MVC

Below is the code to bind @Html.DropDownList in MVC with static values.

<div class="form-group">
 @Html.Label("Technology")
 @Html.DropDownList("–Select–", new List<SelectListItem>
{
new SelectListItem{ Text="MVC", Value = "MVC" },
new SelectListItem{ Text="WCF", Value = "WCF" },
new SelectListItem{ Text="Web API", Value = "API" }
})
</div>
Keep your eyes on SharePointCafe.Net for upcoming MVC blogs
You may like a few blogs on MVC-

Leave a Comment

RSS
YouTube
YouTube
Instagram