1 回答
TA贡献1825条经验 获得超6个赞
这是我认为你应该做的,
如果您Action在控制器中是GetStudents,并且您的下拉列表的值为字符串(毕业状态),请将其传递给过滤器按钮上的控制器单击
[HttpPost]
public ActionResult Documents(string? graduationStatus)
{
var graduates = db.Graduated_Students.Where(student => student.GraduationStatus == graduationStatus);
return View(graduates.ToList());
}
请注意,必须与数据库中的string? graduationStatus类型相同student.GraduationStatus
还要确保Html.BeginForm()对控制器有正确的操作
@Html.BeginForm("GetStudents", "Controller", FormMethod.Post, new { @class = "my_form"})
编辑:
将下面的行更改为
@Html.DropDownList("GraduationStatus", new SelectList(ViewBag.GraduationStatus, "Value Here", "Text Here", null), "- Select -", new { @class = "form-control"})
- 1 回答
- 0 关注
- 117 浏览
添加回答
举报