开发者

MVC3 Razor SelectList.MakeSelection issue

I'm working on a MVC3 web application. I want a list of rotation shown in view. But during build I get error:

Error 2971 'System.Web.Mvc.SelectList' does not contain a definition for 'MakeSelection' and no extension method 'MakeSelection' accepting a first argument of type 'System.Web.Mvc.SelectList' could be found (are you missing a using directive or an assembly reference?).

My code in view:

<div class="editor-field">
    @Html.DropDownListFor(model => model.JobFiles[i].JobPages[j].UserRotation, (ViewData["rotation"] as SelectList).MakeSelection(Model.JobFiles[i].JobPages[j].UserRotation))
</div>
开发者_如何学Python

Please help. Thx in advance.


You error is telling you that the MakeSelection function does not belong to the System.Web.Mvc.SelectList object. I did find this extension method -

public static SelectList MakeSelection(this SelectList list, object selection)
{
    return new SelectList(list.Items, list.DataValueField, list.DataTextField, selection);
} 

in this question, are you missing the extension method from your code?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜