forum

Home / DeveloperSection / Forums / Create Dropdown in MVC with static value

Create Dropdown in MVC with static value

Anonymous User 1183 14-Dec-2017

Hi Expert,

I want to change way of create dropdown menu in my razor view.

Here is my code:

<div class="col-md-6">

                                @{
        List<SelectListItem> listItems = new List<SelectListItem>();
        listItems.Add(new SelectListItem { Text = "Approved", Value = "A" });
        listItems.Add(new SelectListItem { Text = "Pending", Value = "P", Selected = true });
        listItems.Add(new SelectListItem { Text = "Rejected", Value = "R" });
                                }
                                <label for="status">Status</label>
                                @Html.DropDownListFor(model => model.Status, listItems, "-- Select Status --", new { @class = "form-control" })
                            </div>

Please give me some solution to achieve this task.


Updated on 14-Dec-2017
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By