Finished 'ViewData in ASP.NET MVC'
parent
33c8722583
commit
2d19c8578d
|
@ -11,10 +11,14 @@ namespace FirstMVCDemo.Controllers
|
||||||
public class HomeController : Controller
|
public class HomeController : Controller
|
||||||
{
|
{
|
||||||
// GET: Home
|
// GET: Home
|
||||||
public ActionResult Index(int id)
|
public ActionResult Index()
|
||||||
{
|
{
|
||||||
EmployeeBusinessLayer employeeBL = new EmployeeBusinessLayer();
|
EmployeeBusinessLayer employeeBL = new EmployeeBusinessLayer();
|
||||||
Employee employee = employeeBL.GetEmployeeDetails(id);
|
Employee employee = employeeBL.GetEmployeeDetails(102);
|
||||||
|
|
||||||
|
ViewData["Employee"] = employee;
|
||||||
|
ViewData["Header"] = "Employee Details";
|
||||||
|
|
||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,9 +8,42 @@
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta name="viewport" content="width=device-width" />
|
<meta name="viewport" content="width=device-width" />
|
||||||
<title>Index</title>
|
<title>Page Title</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
@{
|
||||||
|
var employee = ViewData["Employee"]
|
||||||
|
as FirstMVCDemo.Models.Employee;
|
||||||
|
}
|
||||||
|
|
||||||
|
<h2>@ViewData["Header"]</h2>
|
||||||
|
<table style="font-family:Arial">
|
||||||
|
<tr>
|
||||||
|
<td>Employee ID:</td>
|
||||||
|
<td>@employee.EmployeeId</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Name:</td>
|
||||||
|
<td>@employee.Name</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Gender:</td>
|
||||||
|
<td>@employee.Gender</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>City:</td>
|
||||||
|
<td>@employee.City</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Salary:</td>
|
||||||
|
<td>@employee.Salary</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Address:</td>
|
||||||
|
<td>@employee.Address</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<h1>Index View Coming From Views/Home Folder</h1>
|
<h1>Index View Coming From Views/Home Folder</h1>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue