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?
精彩评论