Finished 'ViewBag in ASP.NET MVC'
parent
07956d2d3c
commit
a875b59057
|
@ -14,10 +14,10 @@ namespace FirstMVCDemo.Controllers
|
||||||
public ActionResult Index()
|
public ActionResult Index()
|
||||||
{
|
{
|
||||||
EmployeeBusinessLayer employeeBL = new EmployeeBusinessLayer();
|
EmployeeBusinessLayer employeeBL = new EmployeeBusinessLayer();
|
||||||
Employee employee = employeeBL.GetEmployeeDetails(102);
|
Employee employee = employeeBL.GetEmployeeDetails(101);
|
||||||
|
|
||||||
ViewData["Employee"] = employee;
|
ViewBag.Employee = employee;
|
||||||
ViewData["Header"] = "Employee Details";
|
ViewBag.Header = "Employee Details";
|
||||||
|
|
||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,11 +12,10 @@
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@{
|
@{
|
||||||
var employee = ViewData["Employee"]
|
var employee = ViewBag.Employee;
|
||||||
as FirstMVCDemo.Models.Employee;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
<h2>@ViewData["Header"]</h2>
|
<h2>@ViewBag.Header</h2>
|
||||||
<table style="font-family:Arial">
|
<table style="font-family:Arial">
|
||||||
<tr>
|
<tr>
|
||||||
<td>Employee ID:</td>
|
<td>Employee ID:</td>
|
||||||
|
|
Loading…
Reference in New Issue