Finished 'ViewBag in ASP.NET MVC'
parent
07956d2d3c
commit
a875b59057
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in New Issue