【发布时间】:2017-11-06 12:56:48
【问题描述】:
我正在开发一个医疗应用程序。我有下拉列表包括患者姓名。单击下拉列表时,如何重定向到显示所选患者生命体征的视图。我使用实体框架将数据绑定到下拉列表。
this is what I did.
//Controller
public ViewResult PatientLIstView()
{
PatientListdbEntities dbcontext = new PatientListdbEntities();
var getPatientlist = dbcontext.Patient_Reg.ToList();
SelectList list = new SelectList(getPatientlist, "Preg_id", "P_Name");
ViewBag.patients = list;
return View();
}
// this is the view
@{
ViewBag.Title = "PatientLIstView";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<div class="page-content-wrapper">
<div class="page-content">
<table align="center" style="margin-top:8%;margin-left:18%">
<tr>
<td>Patient List</td>
<td>@Html.DropDownList("paients1", ViewBag.patients as SelectList,
"---select---")</td></tr>
</table>
@*@Html.DropDownList("paients1", ViewBag.patients as SelectList, "---
select---", new { style = "height: 100px;" })*@
</div>
</div>
现在我有了患者名单。如何在控制器中获取下拉选择的值,以便我可以在另一个视图中显示相应的患者信息?
【问题讨论】:
-
您需要 javascript 来响应客户端事件(或者只需将表单提交给重定向到页面的方法)
标签: c# asp.net asp.net-mvc asp.net-mvc-5