Hi All
I have written an Enum extension method that allows me to create a view model and allows me to easily bind a generic Enum to a SelctList like:
this.ProductStatusList = new ProductStatusTypes().BindToSelectList<ProductStatusTypes>
(product.Status.ToString());
In my View I can then have:
<% using (Html.BeginForm()) {%>
<fieldset>
<legend>Fields</legend>
<%= Html.EditorForModel() %>
<%=Html.DropDownListFor(p => p.ProductStatusList, new
SelectList(Model.ProductStatusList, "Value", "Text",
Model.Status.ToString()))%>
<p>
<input type="submit" value="Create" />
</p>
</fieldset>
<% } %>
Notice I am using EditorForModel and then a seperate DropDownList.
My question is: Is there a way to get the EditorForModel to be clever enough to pick up that I want to use a SelectList instead of a TextBox for status?
Many Thanks
Ted