How to bind Dropdown list with hard code values in MVC

In my previous blogs, you can read about MVC.
In this blog, we will see how to bind @Html.DropDownList with static values.

Bind Static values with a Dropdown list in MVC

Below is the code to bind 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 few blogs on MVC-

Comments

Popular

What's new in C# 6.0 language - All new features of C# 6.0 for developers

SharePoint Interview Questions and Answers