amir_arsalan_k2
پنج شنبه 06 آبان 1395, 09:26 صبح
من بالای صفحه Category دارم که میخوام پیج لیست با Category درست عمل کنه اما وقتی صفحه ۲ میزنم کّل محصولات دوباره میاره ....
143210
کد های صفحه View
foreach (var item in ViewBag.shoescat)
{
<a class="" href="@Url.Action("WomenShop", "Home", new { shoes = item.id })" style="padding:0 15px; font-weight:bold; text-transform: uppercase">@item.name</a>
}
foreach (var item in Model)
{
<img src="~/Uploads/PD/@item.pic_main" alt="" style="padding-top:200px">
}
<div class="col-md-12">
<center>
@Html.PagedListPager(Model, page => Url.Action("WomenShop", new { page, shoes = 0}))
Page @(Model.PageCount < Model.PageNumber ? 0 : Model.PageNumber) of @Model.PageCount
</center>
</div>
من میخواستم مقدار item.id در line 3 به shoes در pagedlist پاس بدم ... اما .... :گریه:
amir_arsalan_k2
دوشنبه 10 آبان 1395, 05:23 صبح
کسی کمک نمی کنه ....:متفکر:
parsdarab
سه شنبه 11 آبان 1395, 21:25 عصر
کد سمت سرورت مشکل داره
parsdarab
سه شنبه 11 آبان 1395, 21:28 عصر
کد سمت ویو
<nav> <ul class="pagination">
@if ((int)ViewBag.pageId > 1)
{
<li class="">
<a aria-label="Previous" href="@Url.Action("Last", "Content", protocol: "http", routeValues: new { page = ViewBag.pageId-1 })"><span aria-hidden="true">«</span></a>
</li>
}
else
{
<li class="">
<a aria-label="Previous" href="#"><span aria-hidden="true">«</span></a>
</li>
}
@for (int i = 1; i <= (ViewBag.pageCount + 1); i++)
{
<li class="@(((int)ViewBag.pageId==i)?"active":"")">
<a href="@Url.Action("Last", "Content", new { page = i })">@(i)</a>
</li>
}
@if ((int)ViewBag.pageId < (int)ViewBag.pageCount + 1)
{
<li class="">
<a aria-label="Next" href="@Url.Action("Last", "Content", protocol: "http", routeValues: new { page = ViewBag.pageId+1 })"><span aria-hidden="true">»</span></a>
</li>
}
else
{
<li class="">
<a aria-label="Previous" href="#"><span aria-hidden="true">»</span></a>
</li>
}
</ul>
</nav>
سمت سرور
public ActionResult Last(int? page) {
const int pageItem = 2;
int skip = ((page ?? 1) - 1) * pageItem;
var lstResult = _contentService.Content_Last(pageItem, skip).ToList();
int pagecount = (_contentService.Content_GetActiveCount() - 1) / pageItem;
if (page > pagecount + 1)
{
//throw new HttpException("404");
//تولید خطا دستی
throw new HttpException(404, "HTTP/1.1 404 Not Found");
}
ViewBag.pageCount = pagecount;
ViewBag.pageId = (page ?? 1);
if (!lstResult.Any())
{
return View(new List<PartialViewContent>());
}
//انتخاب فیلدهای مورد نظر
var Models = (from employee in lstResult
select new PartialViewContent
{
Id = employee.Id,
Caption = employee.Caption,
Description = employee.Description,
Body = employee.Body,
Tags = employee.TagNamesSplite,
ViewCount = employee.ViewCount,
CommentCount = employee.CommentCount,
Publishdatetime = employee.PublishedOn,
Link1 =
Url.Action(actionName: "Post",
controllerName: "Content",
protocol: "http",
routeValues: new { id = employee.Id, name = employee.Caption }),
}).ToList();
return View(Models);
}
vBulletin® v4.2.5, Copyright ©2000-1404, Jelsoft Enterprises Ltd.