Я не совсем уверен в своих лямбдах, но почему не работает следующее?4 / mvc2
Работает:
// SpotlightsController.cs
public class SpotlightFormViewModel
{
// props
public Spotlight Spotlight { get; private set; }
public SelectList Featured { get; private set; }
public IDictionary<string, int> feature = new Dictionary<string, int>(){
{"True", 1},
{"False", 0},
};
// constr
public SpotlightFormViewModel(Spotlight spotlight)
{
Spotlight = spotlight;
Featured = new SelectList(feature.Keys, spotlight.Featured);
}
}
// Edit.aspx
<div class="editor-label">
<label for="Featured">Featured:</label>
</div>
<div class="editor-field">
<%: Html.DropDownList("Featured", Model.Featured)%>
<%: Html.ValidationMessage("Featured") %>
</div>
Не работает:
// Compiler Error Message: CS1501: No overload for method 'DropDownListFor' takes 1 arguments
// Edit.aspx
<div class="editor-label">
<%: Html.LabelFor(model => model.Featured) %>
</div>
<div class="editor-field">
<%: Html.DropDownListFor(model => model.Featured)%>
<%: Html.ValidationMessageFor(model => model.Featured) %>
</div>