0
我正在做一個asp.net mvc項目。我想在視圖中顯示特定人員的詳細信息。我必須加入兩個表來顯示數據。對於我所做的:從控制器顯示特定用戶數據以查看
控制器:
[HttpGet]
public ViewResult DisplayData()
{
ViewBag.Designation1up = new SelectList(db.Designations, "Designation1up", "DesignationInternal", "DesignationExternal");
return View();
}
[HttpPost]
public ActionResult DisplayData(Employee emp)
{
try
{
object s = Session["EmployeeID"];
var sessval = s.ToString();
var data1 = (from e in db.Employees.Where(c => c.EmployeeID == sessval) join d in db.Designations on e.Designation1up equals d.Designation1up select e).SingleOrDefault();
return View(data1);
}
catch (Exception e)
{
}
ViewBag.Designation1up = new SelectList(db.Designations, "Designation1up", "DesignationInternal",emp.Designation1up);
return View(emp);
}
的觀點:
<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<ResourceTracking.ViewModel.AdminDetailsModel>" %>
<!DOCTYPE html>
<html>
<head runat="server">
<title>DisplayData</title>
</head>
<body>
<fieldset>
<legend>AdminDetailsModel</legend>
<div class="display-label">EmployeeID</div>
<div class="display-field"> <%: Html.DisplayFor(model => model.EmployeeID) %> </div>
<!--...(same DIV 4 other fields)-->
</fieldset>
</body>
</html>
我的問題是,當我調試的代碼,編譯器是不會到HttpPost
方法。它只是調試HttpGet
方法並給出輸出,但除非運行HttpPost
,否則輸出將不正確。我應該怎麼做?
你能顯示相應的看法? – 2013-02-25 13:03:36
<%@頁面語言= 「C#」 繼承= 「System.Web.Mvc.ViewPage」 %> <!DOCTYPE HTML> <頭RUNAT = 「服務器」> DisplayData