Finished 'ViewBag in ASP.NET MVC'

master
jason.zhu 2021-06-10 22:09:39 +10:00
parent 07956d2d3c
commit a875b59057
2 changed files with 5 additions and 6 deletions

View File

@ -14,10 +14,10 @@ namespace FirstMVCDemo.Controllers
public ActionResult Index()
{
EmployeeBusinessLayer employeeBL = new EmployeeBusinessLayer();
Employee employee = employeeBL.GetEmployeeDetails(102);
Employee employee = employeeBL.GetEmployeeDetails(101);
ViewData["Employee"] = employee;
ViewData["Header"] = "Employee Details";
ViewBag.Employee = employee;
ViewBag.Header = "Employee Details";
return View();
}

View File

@ -12,11 +12,10 @@
</head>
<body>
@{
var employee = ViewData["Employee"]
as FirstMVCDemo.Models.Employee;
var employee = ViewBag.Employee;
}
<h2>@ViewData["Header"]</h2>
<h2>@ViewBag.Header</h2>
<table style="font-family:Arial">
<tr>
<td>Employee ID:</td>