iT邦幫忙

0

想請問我該如何把這些資料顯示給前端

想請問我該如何把這些資料傳給前端並顯示?

https://ithelp.ithome.com.tw/upload/images/20190306/20110132rUVdmv5iRt.jpg

controller

  var x = HisSrv.FindAkHistoryLastThreeTimes(model.DocOrder.PATNO);

FindAkHistoryLastThreeTimes方法

public List<OpdHistoryModel> FindAkHistoryLastThreeTimes(string PatNo)
        {
            return hisRepository.GetAkHistoryLastThreeTimes(PatNo);
        }

我想顯示的前端

  @Html.TextAreaFor(m => m.DocOrder.NOTE, new { @class = "form-control", @rows = "8", @style = "width:100%;"})                           
小魚 iT邦大師 1 級 ‧ 2019-03-06 17:34:41 檢舉
為什麼這年頭都不喜歡寫Html XD
tenno081 iT邦研究生 4 級 ‧ 2019-03-06 17:39:27 檢舉
需要時還是會改回來XD這方便咩
小魚 iT邦大師 1 級 ‧ 2019-03-06 18:33:40 檢舉
我是都直接寫Html,
而且用Html的方式不只ASP.NET MVC,
其他的後端也都可以用.
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 個回答

0
JamesDoge
iT邦高手 1 級 ‧ 2023-02-03 08:26:49

Controller:

public class YourController : Controller
{
    private IHisSrv HisSrv { get; set; }
    public YourController(IHisSrv hisSrv)
    {
        HisSrv = hisSrv;
    }

    public ActionResult YourAction(YourModel model)
    {
        var akHistory = HisSrv.FindAkHistoryLastThreeTimes(model.DocOrder.PATNO);
        List<string> historyList = new List<string>();
        foreach (var item in akHistory)
        {
            historyList.Add($"{item.VisitDate}: {item.Diagnosis}");
        }
        model.DocOrder.NOTE = string.Join("\n", historyList);
        return View(model);
    }
}

View:

@model YourProject.Models.YourModel

@Html.TextAreaFor(m => m.DocOrder.NOTE, new { @class = "form-control", @rows = "8", @style = "width:100%;"})

我要發表回答

立即登入回答