Skip to content

Instantly share code, notes, and snippets.

@geocine
Created August 20, 2013 03:30
Show Gist options
  • Select an option

  • Save geocine/6276822 to your computer and use it in GitHub Desktop.

Select an option

Save geocine/6276822 to your computer and use it in GitHub Desktop.
PagedList Sample on View
<div class="box">
<div class="form-head box-title">
<h3><i class="icon-th-list"></i>Time Entry Status</h3>
</div>
<div>
@using (Html.BeginForm("Data", "Status", FormMethod.Get))
{
<div class="control-group search">
<div class="input-xxlarge">
@Html.TextBox("q", ViewBag.CurrentFilter as string, new { placeholder = "Search here..." })
<button class="btn btn-primary help-inline">Search</button>
</div>
</div>
}
</div>
<table id="users" class="table table-hover table-nomargin table-bordered">
<thead>
<tr>
<th>
@Html.ActionLink("Username", "Data", new { s=ViewBag.UsernameSortParm, f=ViewBag.CurrentFilter })
</th>
<th>
@Html.ActionLink("Date", "Data", new { s=ViewBag.DateSortParm, f=ViewBag.CurrentFilter })
</th>
<th>
@Html.ActionLink("Hours", "Data", new { s=ViewBag.HoursSortParm, f=ViewBag.CurrentFilter })
</th>
<th>
@Html.ActionLink("Alert", "Data", new { s=ViewBag.AlertSortParm, f=ViewBag.CurrentFilter })
</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model) {
<tr>
<td>@Html.DisplayFor(modelItem => item.UserName)</td>
<td>@Html.Raw(item.Date == null ? "" : DateTime.Parse(item.Date.ToString()).ToShortDateString())</td>
<td>@Html.Raw(item.Hours == null ? "" : item.Hours.ToString())</td>
<td>@Html.DisplayFor(modelItem => item.Alert)</td>
</tr>
}
</tbody>
</table>
Page <b>@(Model.PageCount < Model.PageNumber ? 0 : Model.PageNumber)</b> of <b>@Model.PageCount</b>
@Html.PagedListPager( Model, p => Url.Action("Data", "Status", new { p, s = ViewBag.CurrentSort, f=ViewBag.CurrentFilter }) )
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment