MVC 2: verwenden von Html.DropDownListFor?

Ich bin mir nicht ganz sicher auf meine lambda noch nicht, aber warum nicht die folgenden arbeiten? 4/mvc2

Funktioniert:

//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>

Nicht funktioniert:

//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>
InformationsquelleAutor ryan | 2010-07-13
Schreibe einen Kommentar