Skip to content

Instantly share code, notes, and snippets.

@Tesla9527
Created November 22, 2015 10:16
Show Gist options
  • Save Tesla9527/3d3876b5d9ca14bbc961 to your computer and use it in GitHub Desktop.
Save Tesla9527/3d3876b5d9ca14bbc961 to your computer and use it in GitHub Desktop.
-----------------------------
Below is code in Employee.cs
-----------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace WebApplication2.Models
{
public class Employee
{
public int EmployeeId { get; set; }
public string Name { get; set; }
public string Gender { get; set; }
public string City { get; set; }
}
}
-----------------------------
Below is code in EmployeeController.cs
-----------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using WebApplication2.Models;
namespace WebApplication2.Controllers
{
public class EmployeeController : Controller
{
// GET: Employee
public ActionResult Details()
{
Employee employee = new Employee()
{
EmployeeId = 101,
Name = "Tesla",
Gender = "Male",
City = "Shanghai"
};
return View(employee);
}
}
}
-----------------------------
Below is code in Details.cshtml under folder Employee
-----------------------------
@model WebApplication2.Models.Employee
@{
ViewBag.Title = "Employee Details";
}
<h2>Employee Details</h2>
<table style="font-family:Arial">
<tr>
<td>
<b>Employee Id:</b>
</td>
<td>
@Model.EmployeeId
</td>
</tr>
<tr>
<td>
<b>Name:</b>
</td>
<td>
@Model.Name
</td>
</tr>
<tr>
<td>
<b>Gender:</b>
</td>
<td>
@Model.Gender
</td>
</tr>
<tr>
<td>
<b>City:</b>
</td>
<td>
@Model.City
</td>
</tr>
</table>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment