1

我正在使用 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>

我的代码有什么问题,任何人都可以帮助我......提前谢谢......

4

1 回答 1

0
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>
于 2012-10-16T06:56:35.257 回答