尝试将在本例中为studentid的选定值传递给BeginForm。
@using (Html.BeginForm("DDSubmit", "Home",new { id=Model.studentID}, FormMethod.Post))
{
@Html.DropDownListFor(m => m.studentID, Model.DDList, "Please Select",new { onchange = "this.form.submit();" })
}
public ActionResult DDSubmit(int id)
{
var info = (from r in entity.STUDENTS where r.Student_Id == id select r).ToList();
return View(info);
}
public class DDModel
{
public List<SelectListItem> DDList { get; set; }
public int studentID { get; set; }
public string studentName { get; set; }
}
答案 0 :(得分:0)
终于想通了
@using (Html.BeginForm("DDSubmit", "Home", FormMethod.Post))
{
@Html.DropDownListFor(m => m.studentID, Model.DDList, "Please Select",new { onchange = "this.form.submit();" })
}
public ActionResult DDSubmit(DDModel ddlist)
{
int id = ddlist.studentID;
var info = (from r in entity.STUDENTS where r.Student_Id == id select r).ToList();
return View(info);
}