Skip to content

Instantly share code, notes, and snippets.

@A2H111
Created October 22, 2017 04:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save A2H111/c6ee953682c13980c4ed84e3a394d619 to your computer and use it in GitHub Desktop.
Save A2H111/c6ee953682c13980c4ed84e3a394d619 to your computer and use it in GitHub Desktop.
@page
@using NetCoreRazorPageApp.Model
@using Microsoft.EntityFrameworkCore;
@inject EmployeeDbContext dbcontext
@functions {
public IEnumerable<NetCoreRazorPageApp.Model.Employee> Employees { get; set; }
public async Task OnGetAsync()
{
//Retreive 10 records from database
Employees = await dbcontext.Employee.Take(10).ToListAsync();
}
}
<form method="post">
<br /><br />
<a asp-page="/CreatePage" class="btn btn-primary">Create</a>
<br /><br />
Details
<table class="table table-sm table-bordered table-striped">
<thead class="green-gray lighten-4">
<tr>
<th>Employee ID</th>
<th>Employee Name</th>
<th>Employee Address</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model.Employees)
{
<tr>
<td>@item.EmployeeID</td>
<td>@item.EmployeeName</td>
<td>@item.EmployeeAddress</td>
<td><a asp-page="/EditPage" asp-route-id="@item.EmployeeID">Edit</a> | <a asp-page="/DeletePage" asp-route-id="@item.EmployeeID">Delete</a> </td>
</tr>
}
</tbody>
</table>
</form>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment