Asp.net mvc 3 没有类型为';IEnumerable<;选择列表项>';这是关键;学生;。错误
Iam使用ASP.Net MVC3 Razor 我有一个绑定数据的控制器Asp.net mvc 3 没有类型为';IEnumerable<;选择列表项>';这是关键;学生;。错误,asp.net-mvc-3,Asp.net Mvc 3,Iam使用ASP.Net MVC3 Razor 我有一个绑定数据的控制器 public Actionresult Index() { ViewBag.student= new SelectList(db.Collection, "ID", "Name"); ViewBag.student1= new SelectList(db.Collection, "ID", "Name"); return view(); } 这是我的看法 <table> &l
public Actionresult Index()
{
ViewBag.student= new SelectList(db.Collection, "ID", "Name");
ViewBag.student1= new SelectList(db.Collection, "ID", "Name");
return view();
}
这是我的看法
<table>
<tr>
<td>
@Html.DropDownList("student")
</td>
<td>
@Html.DropDownList("student1")
</td>
</tr>
</table>
@Html.DropDownList(“学生”)
@Html.DropDownList(“student1”)
我的代码有什么问题,谁能帮我。。。
Thanx提前..公共行动结果索引()
public Actionresult Index()
{
ViewBag.studentList = new SelectList(db.Collection, "ID", "Name");
ViewBag.student1List = new SelectList(db.Collection, "ID", "Name");
return view();
}
<table>
<tr>
<td>
@Html.DropDownList("student", (SelectList)ViewBag.studentList)
</td>
<td>
@Html.DropDownList("student1", (SelectList)ViewBag.student1List)
</td>
</tr>
</table>
{
ViewBag.studentList=新选择列表(db.Collection,“ID”,“Name”);
ViewBag.student1List=新的选择列表(db.Collection,“ID”,“Name”);
返回视图();
}
@Html.DropDownList(“学生”,(选择列表)ViewBag.studentList)
@Html.DropDownList(“student1”,(SelectList)ViewBag.student1List)
为什么不使用视图模型并定义该属性呢?我也这样做了,但得到了相同的错误。我喜欢@Html.dropDownList(model=>model.ID,ViewData[“student”]作为IEnumerable,“Select One”,new{@ID=“ddlstuent”}@user1603121您在其他代码中有错误@Html.DropDownList(“学生”)
-其中student
只是表单字段的名称。