0
嗨,我是新来的MVC 3只是一个初学者。我试图在视图中创建一个新的下拉框,但我得到错误说''System.Web.Mvc.HtmlHelper'不包含'DropDownListFor'的定义和最好的扩展方法重载'System.Web。 Mvc.Html.SelectExtensions.DropDownListFor(System.Web.Mvc.HtmlHelper,System.Linq.Expressions.Expression>,System.Collections.Generic.IEnumerable)'有一些无效参数“。MVC 3.下拉框
这里是查看代码
<tr>
<td>
<label>
Customer Name
</label>
</td>
<td>
@Html.DropDownListFor(A => A.Roles, Model.Roles);
</td>
</tr>
控制器代码
public ActionResult Index()
{
var Model = new Customer();
Model.Roles = getRoles();
return View(Model);
}
private List<string> getRoles()
{
List<string> roles = new List<string>
{
"Developer",
"Tester",
"Project Manager",
"Team Lead",
"QA"
};
return roles;
}
感谢它的工作.. –