1 回答

TA貢獻(xiàn)1825條經(jīng)驗(yàn) 獲得超6個(gè)贊
這是我認(rèn)為你應(yīng)該做的,
如果您Action在控制器中是GetStudents,并且您的下拉列表的值為字符串(畢業(yè)狀態(tài)),請將其傳遞給過濾器按鈕上的控制器單擊
[HttpPost]
public ActionResult Documents(string? graduationStatus)
{
var graduates = db.Graduated_Students.Where(student => student.GraduationStatus == graduationStatus);
return View(graduates.ToList());
}
請注意,必須與數(shù)據(jù)庫中的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 關(guān)注
- 159 瀏覽
添加回答
舉報(bào)