In asp.net Mvc3 razor, I have binded some data with dbcontext in my controller viewbag using selectlist
My controller..
public ActionResult Index()
{
ViewBag.students = new SelectList(db.StudentList, "StudentID", "StudentName");
return View();
}
Then I binded it to the ListBox using viewbag
My View..
@using (Html.BeginForm("Save", "Student"))
{
@Html.ValidationSummary(true)
<div>
@Html.ListBox("students")
<p>
<input type="submit" name="Save" id="Save" value="Save" />
</p>
</div>
}
Now, in my controller, in that Save action, I need to capture the listbox selected values I have tried the following
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Save(FormCollection formValue)
{
//need code to capture values
return View("Index");
}
Could anyone help
Thanks in advance