Controller
public ActionResult Listele()
{
return View();
}
[HttpPost]
public ActionResult Listele(int page = 1)
{
return View(OgrenciVeri.Ogrenciler.OrderBy(x => x.Ad).ToPagedList(page, 2));
}
model ekliyorum
public class Ogrenci
{
public int Id { get; set; }
public string Ad { get; set; }
public string Soyad { get; set; }
public string TcKimlikNo { get; set; }
public string BolumAd { get; set; }
public string GirisYil { get; set; }
}
namespace WebApplication15.Veri
{
public class OgrenciVeri
{
public static List<Ogrenci> Ogrenciler = new List<Ogrenci>
{
new Ogrenci
{
Id=1,
Ad="sadsadsa",
Soyad="sadsfqwq",
BolumAd="Tıp",
TcKimlikNo="24944431034",
GirisYil="2013"
},
new Ogrenci
{
Id=2,
Ad="Neslişanah",
Soyad="Yakutmur",
BolumAd="Tcp",
TcKimlikNo="24944331034",
GirisYil="2013"
},
new Ogrenci
{
Id=3,
Ad="sadsadsad",
Soyad="asdsadsads",
BolumAd="Tcsaaaqp",
TcKimlikNo="24944331034",
GirisYil="2013"
},
new Ogrenci
{
Id=4,
Ad="qewqewq",
Soyad="wqewqw",
BolumAd="ojjkjk",
TcKimlikNo="24944331034",
GirisYil="2013"
}
};
}
}
veri adında bir klasor tanımlayıp icinde ve list olusturuyorum ama hata alıyorum view aşağıdaki gibidir ve sayfa numaralama olmuyor hata ile karsılasıyorum
@model IEnumerable<WebApplication15.Models.Ogrenci>
@{
ViewBag.Title = "Listele";
}
<h2>Listele</h2>
<p>
@Html.ActionLink("Yeni Kayıt", "Yeni")
</p>
<table class="table">
<tr>
<th>
@Html.DisplayNameFor(model => model.Ad)
</th>
<th>
@Html.DisplayNameFor(model => model.Soyad)
</th>
<th>
@Html.DisplayNameFor(model => model.TcKimlikNo)
</th>
<th>
@Html.DisplayNameFor(model => model.BolumAd)
</th>
<th>
@Html.DisplayNameFor(model => model.GirisYil)
</th>
<th></th>
</tr>
@foreach (var item in Model) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.Ad)
</td>
<td>
@Html.DisplayFor(modelItem => item.Soyad)
</td>
<td>
@Html.DisplayFor(modelItem => item.TcKimlikNo)
</td>
<td>
@Html.DisplayFor(modelItem => item.BolumAd)
</td>
<td>
@Html.DisplayFor(modelItem => item.GirisYil)
</td>
<td>
@Html.ActionLink("Düzenle", "Edit", new { id=item.Id }) |
@Html.ActionLink("Details", "Details", new { id=item.Id }) |
@Html.ActionLink("Delete", "Delete", new { /* id=item.PrimaryKey */ })
</td>
</tr>
}
</table>