@model ACG6MvcAdHcApi.ViewModels.ProductForeachViewModel @{ ViewBag.Title = "List of Products"; Layout = "~/Views/Shared/_Layout.cshtml"; string bgColor = "#F7F6F3"; } @section AdditionalJavaScript { <script src="~/js/jqgrid-listforeach.js" asp-append-version="true"></script> <script type="text/javascript"> var urlAndMethod = '/Product/Delete/'; </script> } <h2>@ViewBag.Title</h2> <br /><br /> <div id="errorConfirmationDialog"></div> <div id="errorDialog"></div> <a href="@Url.Action("Add", "Product", new { urlReferrer = "/Product/ListForeach" })"><img src="@Url.Content("~/images/Add.gif")" alt="Add New Product" style="border: none;" /></a> @Html.ActionLink("Add New Product", "Add", "Product", new { urlReferrer = "/Product/ListForeach" }) <br /><br /> <table class="gridviewGridLines" cellspacing ="0" cellpadding="8" style="width:100%;border-collapse:collapse;"> <tr style="color:#2E6E9E;background-color:#DFEFFC;font-weight:bold;"> @for (int i = 0; i < Model.ProductFieldNames.GetLength(0); i++) { string fieldName = Model.ProductFieldNames[i, 0]; string title = Model.ProductFieldNames[i, 1]; if (Model.FieldToSortWithOrder.Contains(fieldName) && Model.FieldToSortWithOrder.Contains("asc")) { <td><a href="?sidx=@fieldName&sord=desc" style="color:#2E6E9E;">@title</a>@if (Model.FieldToSortWithOrder == fieldName + " asc") {<img src="@Url.Content("~/images/ArrowUp.png")" alt="" />}</td> } else { <td><a href="?sidx=@fieldName&sord=asc" style="color:#2E6E9E;">@title</a>@if (Model.FieldToSortWithOrder == fieldName + " desc") {<img src="@Url.Content("~/images/ArrowDown.png")" alt="" />}</td> } } <td> </td> <td> </td> </tr> @if (Model.ProductData != null) { foreach (var item in Model.ProductData) { <tr style="color:#333333; background-color:@bgColor;"> <td align="right">@item.ProductID</td> <td>@item.ProductName</td> <td align="right"><a href="~/Supplier/Details/@item.SupplierID?urlReferrer=/Product/ListForeach">@item.SupplierID</a></td> <td align="right"><a href="~/Category/Details/@item.CategoryID?urlReferrer=/Product/ListForeach">@item.CategoryID</a></td> <td>@item.QuantityPerUnit</td> <td align="right">@Convert.ToDouble(item.UnitPrice).ToString("C")</td> <td align="right">@item.UnitsInStock</td> <td align="right">@item.UnitsOnOrder</td> <td align="right">@item.ReorderLevel</td> <td align="center"><span><input type="checkbox" @(item.Discontinued ? "checked=\"checked\"" : "") disabled="disabled" /></span></td> <td align="center" style="width:30px;"> <a href="Update/@item.ProductID?urlReferrer=/Product/ListForeach" title="Click to edit"><img src="@Url.Content("~/images/Edit.gif")" alt="" style="border:none;" /></a> </td> <td align="center" style="width:30px;"> <input type="image" id="imgDelete1" title="Click to delete" src="@Url.Content("~/images/Delete.png")" onclick="deleteItem('@item.ProductID');" style="border-style:none;" /> </td> </tr> bgColor = bgColor == "#F7F6F3" ? "White" : "#F7F6F3"; } } <tr class="gridviewPagerStyle" align="center" style="background-color:#DFEFFC;"> <td colspan="12"> <table> <tr> @if (Model.CurrentPage > Model.NumberOfPagesToShow) { <td><a href="?sidx=@Model.FieldToSort&sord=@Model.FieldSortOrder&page=1" style="color:#000000;">< First</a></td> <td><a href="?sidx=@Model.FieldToSort&sord=@Model.FieldSortOrder&page=@(Model.StartPage - 1)" style="color:#000000;">...</a></td> } @for (int pageNumber = Model.StartPage; pageNumber <= Model.EndPage; pageNumber++) { if (pageNumber == Model.CurrentPage) { <td><span style="font-size:12px;">@pageNumber</span></td> } else { <td><a href="?sidx=@Model.FieldToSort&sord=@Model.FieldSortOrder&page=@pageNumber" style="color:#000000;">@pageNumber</a></td> } } @if (Model.EndPage < Model.TotalPages) { <td><a href="?sidx=@Model.FieldToSort&sord=@Model.FieldSortOrder&page=@(Model.EndPage + 1)" style="color:#000000;">...</a></td> <td><a href="?sidx=@Model.FieldToSort&sord=@Model.FieldSortOrder&page=@Model.TotalPages" style="color:#000000;">Last ></a></td> } </tr> </table> </td> </tr> </table>