Thursday, 31 October 2013

List View

@model IEnumerable<MVCDemo.Models.EmployeeMaster>
@{
    ViewBag.Title = "ListEmployees";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<h2>
    ListEmployees</h2>
<html>
<body>
<div>
    <input type="button" onclick="window.location.href='@Url.Action("Add")'" value="Add"/>
    @*<a href='@Url.Action("Add")' title="Add">Add</a>*@
</div>
    @if (Model.Count() > 0)
    {
        <table width = "100%">
            <tr>
                <td width="5%">
                   Code
                </td>
                <td width="10%">
                    Emp Name
                </td>
                <td width="5%">
                    Gender
                </td>
                <td width="10%">
                    Country
                </td>
                <td width="10%">
                    City
                </td>
                 <td width="10%">
                    DOB
                </td>
                <td width="20%">
                    Age
                </td>
                <td width="8%">
                    Aoccupation
                </td>
                 <td width="5%">
                    Edit
                </td>
                 <td width="5%">
                    Delete
                </td>
            </tr>
            @foreach (var item in Model)
            {
                <tr>
                    <td>
                        @Html.DisplayFor(modelItem => item.EmpCode)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.EmpName)
                    </td>
                    <td>
                       @Html.DisplayFor(modelItem => item.Gender)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.CountryMaster.CountryName)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.CityMaster.CityName)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.DOB)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.Age)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.Occupation)
                    </td>
                    <td>
                        <a href = '@Url.Action("Edit", new { id = item.EmployeeId })' title="Add">Edit</a>
                    </td>
                    <td>
                        <a href = '@Url.Action("DeleteEmp", new { id = item.EmployeeId })' title="Add">Delete</a>
                    </td>
                </tr>
            }
        </table>
    }
</body>
</html>

No comments:

Post a Comment