0

I have been trying to figure out how to get the syntax correct so I can load a drop down list with a simple list of string in MVC.

What is the correct format?

The following code

@Html.DropDownList("VMO", List<string>(ViewBag.VMOList), new { @class = "form-control SearchCriteria", id = "VMO", name = "VMO", multiple = "multiple"})

gives me error

"Non-invocable member 'List<T> cannot be used like a method.
2

1 Answer 1

1

If you want to make a Select List with list of string using @Html.DropDownList() then it should be as follows:

@Html.DropDownList("VMO", new SelectlIst(ViewBag.VMOList),"Select Item", new { @class = "form-control SearchCriteria", id = "VMO", name = "VMO", multiple = "multiple"})

Or If you want to make a Select List with list of object using @Html.DropDownList() then it should be as follows:

@Html.DropDownList("VMO", new SelectlIst(ViewBag.VMOList,"ObjectId","ObjectName"),"Select Item", new { @class = "form-control SearchCriteria", id = "VMO", name = "VMO", multiple = "multiple"})
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.