This works for me but how do I do the same thing using html.dropdownlist?
Notice that the value passed is not the value that is shown to the user.
@model IEnumerable<MVR.Models.ViewIndividual>
<h2>Level1</h2>
<select>
@foreach (var item in Model) {
<option value="@item.Case_Number">@item.Patient_Lastname ,
@item.Patient_Firstname
</option>
}
</select>
As always in an ASP.NET MVC application you start by defining a view model:
then you write a controller action that populates this view model from some data source or something:
and finally you have a strongly typed view using strongly typed helpers:
This being said, because I see that you are not using any view models in your application, you could always try the following ugliness (not recommended, do this at your own risk):
Of course such pornography is not something that I would recommend to ever write in a view and I wouldn’t recommend even to my worst enemies.
Conclusion: In an ASP.NET MVC application you should always be using view models and strongly typed views with strongly typed helpers (see first part of my answer).