嗨我在顯示特定數據方面存在錯誤。我通過模型傳遞了一個參數,並在創建新實例時出錯。這裏是我的代碼:使用存儲過程顯示具有參數的特定數據
控制器
[HttpPost]
[ValidateAntiForgeryToken]
public IActionResult ViewEmployeeSalary(spGetSalaryPerEmployee getsal)
{
var salary = _Context.Set<spGetSalaryPerEmployee>().FromSql("spGetSalaryPerEmployee @empID = {0}", getsal.EmployeeID).AsNoTracking();
return View(salary);
}
查看 此,您單擊重定向到的詳細信息頁面
@foreach(var item in Model)
{
a class="btn btn-primary btn-sm" asp-controller="Salary" asp-action="ViewEmployeeSalary" asp-route-id="@item.EmployeeId"><span class="glyphicon glyphicon-dashboard" style="vertical-align:middle;margin-top: -5px"></span> Salary Details</a>
}
這裏是按鈕該頁面,它認爲細節
@model PEMCOLoan.DAL.Entities.spModels.spGetSalaryPerEmployee
@{
ViewBag.Title = "Salary Details";
}
<h2>@Html.DisplayFor(model => model.FullName)'s Salary Details</h2>
<table class="table">
<tr>
<td class="form-horizontal">ID:</td>
<td>@Html.DisplayTextFor(model => model.EmployeeID)</td>
</tr>
<tr>
<td class="form-horizontal">Salary Amount:</td>
<td>@Html.DisplayFor(model => model.Salary)</td>
</tr>
<tr>
<td class="form-horizontal">Remarks:</td>
<td>@Html.DisplayTextFor(model => model.Remarks)</td>
</tr>
</table>
我得到這個錯誤:
我真的不到底發生了什麼,但說的,我需要創建一個實例。 我對asp.net核心和ef核心仍有一點了解,現在仍在學習這種語言。我真的需要你的幫助,因爲我對這種語言有點新。
任何建議將不勝感激!
請不要插入錯誤信息的圖像,而是插入文字。通過鏈接圖片,您不會從搜索引擎中獲取此錯誤的點擊數。 –
請不要強制標籤變成問題標題。閱讀http://stackoverflow.com/help/tagging如何正確使用標籤 – Tseng