在 asp.net Mvc3 razor 中,我使用 selectlist 在我的控制器视图包中将一些数据与 dbcontext 绑定
我的控制器..
public ActionResult Index()
{
ViewBag.students = new SelectList(db.StudentList, "StudentID", "StudentName");
return View();
}
然后我使用 viewbag 将它绑定到 ListBox
我的观点..
@using (Html.BeginForm("Save", "Student"))
{
@Html.ValidationSummary(true)
<div>
@Html.ListBox("students")
<p>
<input type="submit" name="Save" id="Save" value="Save" />
</p>
</div>
}
现在,在我的控制器中,在该保存操作中,我需要捕获列表框选择的值,我尝试了以下操作
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Save(FormCollection formValue)
{
//need code to capture values
return View("Index");
}
谁能帮忙
提前致谢