I'm trying to create a dropdown list that contains all distinct values for ONE column (field) from my database by using the Model
in my view.
I'm actually not sure what the Model
is normally called, but apparently it's NOT a ViewModel. This is the Model
I'm referring to:
@model IEnumerable<Model.Student>
The field that I need is Company
. I'm new to MVC and not sure where to begin so all suggestions are appreciated.
I've also been searching other questions, but can't find one that solves my problem.
Edit: I'm coding in C#, ASP.Net 4.5 and using Razor views.
I ended up with this:
Already tested. It does exactly what I need. Maybe this will help someone, maybe not. It doesn't seem very conventional.