我使用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>
我的代码有什么问题,任何人都可以帮助我...... Thanx提前..
答案 0 :(得分: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>