Sunday, 15 April 2018

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-



No comments:

Post a Comment

Dear Readers, Please post your valuable feedback in the comment section if you like this blog or if you have any suggestions. I would love to hear the same from you. Thanks