Ok, so this is an issue that has bothered me since the first time I started playing with MVC around 3 years ago. Binding to dropdownlists has always been a pain in the arse but there is a neat way to do it for enums by doing this:
@Html.DropDownListFor(model => model.Type, new SelectList(Enum.GetValues(typeof(mediaZone.Common.Models.AssetType)), Model.Type))
Great, but the only problem is that that solution will output something like this:
<select id="Type" name="Type">
<option>Image</option>
<option selected="selected">Video</option>
<option>Website</option>
</select>
What I would like to do is output something like this:
<select id="Type" name="Type">
<option value="1">Image</option>
<option value="2" selected="selected">Video</option>
<option value="3">Website</option>
</select>
We are on version 5 now of MVC, you would think that many many many people have had this issue and don't want to write code to fix it. I really hope someone out there has a one line solution to this niggling issue of mine :)
Cheers, /r3plica