using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace MVCDemo.Models
{
public class Employee
{
public int EmpID { get; set; }
public string EmpName { get; set; }
public string Gender { get; set; }
public string City { get; set; }
public double Salary { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MVCDemo.Models;
namespace MVCDemo.Controllers
{
public class EmployeeController : Controller
{
public ActionResult EmpDetails()
{
Employee emp=new Employee()
{
EmpID=10,
EmpName="Raj",
Gender="Male",
City="Pune",
Salary=25000
};
return View(emp);
}
}
}
@model MVCDemo.Models.Employee
@{
ViewBag.Title = "EmpDetails";
}
<h2>Employee Details</h2><br />
<style>
table, th, td
{
border: 1px solid grey;
border-collapse: collapse;
padding: 5px;
}
table tr:nth-child(odd)
{
background-color: #ffe6e6;
}
table tr:nth-child(even)
{
background-color: #ccffcc;
}
</style>
<table style="font-family:Arial; font-size:medium; color:darkblue">
<tr>
<td><b>EmpID</b></td>
<td >@Model.EmpID</td>
</tr>
<tr>
<td><b>EmpName</b></td>
<td>@Model.EmpName</td>
</tr>
<tr>
<td><b>Gender</b></td>
<td>@Model.Gender</td>
</tr>
<tr>
<td><b>City</b></td>
<td>@Model.City</td>
</tr>
<tr>
<td><b>Salary</b></td>
<td>@Model.Salary</td>
</tr>
</table>