2017-11-06 3 views
0

私は医療用アプリケーションの開発に取り組んでいます。私はドロップダウンリストに患者名が含まれています。ドロップダウンリストをクリックすると、選択した患者のバイタルサインを示すビューにどのようにリダイレクトできますか?エンティティフレームワークを使用してデータをドロップダウンリストにバインドしました。mvc5のhtmlドロップダウンリストをクリックすると、どのように表示にリダイレクトできますか?

 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> 

今私は患者リストを持っています。どのように私は別のビューでそれぞれの患者の情報を表示することができるようにコントローラのドロップダウン選択値を得ることができますか?

+0

クライアント側のイベントに応答するにはjavascriptが必要です(または、ページにリダイレクトするメソッドにフォームを送信するだけです) –

答えて

0

このLineを使用すると、コントローラ内の他のメソッドを呼び出して、患者ID情報を検索して表示することができます。

@Html.DropDownList(@Html.ActionLink("Edit", actionname, controllername, new { Id = Patient }), ViewBag.patients as SelectList, 
"---select---")' 

さらに問題がある場合はお知らせください。

+0

これを行う方法を教えてくれないと "actionname"と "controllername"あなたは "new {Id = Patient}"を意味します。私はMVC初心者です。それで私はなぜこのように求めているのですか? – Abdu

+0

データベースを使用していますか? –

+0

はい。私はEntityフレームワークを使ってdropdowmをバインドしています。 "Preg_id"はドロップダウンの値、 "P_Name"は表示されるテキストです。 – Abdu

関連する問題