There are many examples of the paged lists in the forum, but I couldn't adapt any of them to my own model, what should I do about it, where did I go wrong? I tried a lot, where is the problem?
@using PagedList
@using PagedList.Mvc
@using DDD.Models
@model IPagedList<Model_Table>
@{
ViewBag.Title = "Title";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<h2>mmm</h2>
<div id="table">
<table>
<thead>
<tr>
<th>Şirket Adı</th>
<th>Müşteri Adı</th>
<th>Şehir</th>
</tr>
</thead>
<tbody>
@foreach (var Item in Model)
{
<tr>
<td>@Item.DelilListesi.Select(x=>x.Malzeme_Modeli).FirstOrDefault()</td>
</tr>
}
</tbody>
</table>
@Html.PagedListPager(Model, _sayfaNo => Url.Action("Index", "Home", new { SayfaNo = _sayfaNo }))
</div>
Controller:
using System;
using System.Linq;
using System.Web.Mvc;
using DDD.Models;
using PagedList;
namespace DDDD.Controllers
{
public class DenemeController : Controller
{
// GET: Deneme
DDDEntities _db = new DDDEntities();
public ActionResult Index(int? pagesize)
{
int _pagesize = pagesize ?? 1;
var dddd = from o in _db.table1
join a in _db.table2 on o.table1_ID
equals a.Table2_ID
join c in _db.table3 on a.Table2_ID
equals c.table3_ID.ToString()
select new D1List
{
A1 = o.B1,
A2 = o.B2,
A3 = a.B3,
};
Model_Table model = new Model_Table();
model.D1Lists = dddd.ToList();
model.D1Lists.OrderByDescending(m => m.table_name).ToPagedList<D1List>(_pagesize, 10);
return View(model);
}
}
}