Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/asp.net-mvc-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net mvc 3 没有类型为';IEnumerable<;选择列表项>';这是关键;学生;。错误_Asp.net Mvc 3 - Fatal编程技术网

Asp.net mvc 3 没有类型为';IEnumerable<;选择列表项>';这是关键;学生;。错误

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

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>
<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
只是表单字段的名称。