Controller
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
public ActionResult test() { #region data List<Personel> p = new List<Personel>(); p.Add(new Personel { Id = 1, Ad = "ahmet", Soyad = "başdan", KimlikNo = 943456489, MedeniDurum = "bekar", Il = "Düzce", Ilce = "Cumayeri", Yas = 21 }); p.Add(new Personel { Id = 2, Ad = "mehmet", Soyad = "yılmaz", KimlikNo = 746483459, MedeniDurum = "evli", Il = "İstanbul", Ilce = "Üsküdar", Yas = 54 }); p.Add(new Personel { Id = 3, Ad = "ali", Soyad = "bulut", KimlikNo = 985456489, MedeniDurum = "evli", Il = "Düzce", Ilce = "Kaynaşlı", Yas = 32 }); p.Add(new Personel { Id = 4, Ad = "haydar", Soyad = "koç", KimlikNo = 489456489, MedeniDurum = "bekar", Il = "Amasya", Ilce = "Merzifon", Yas = 45 }); p.Add(new Personel { Id = 5, Ad = "kemal", Soyad = "su", KimlikNo = 562456489, MedeniDurum = "evli", Il = "Düzce", Ilce = "Kaynaşlı", Yas = 32 }); p.Add(new Personel { Id = 6, Ad = "cihan", Soyad = "pak", KimlikNo = 456456489, MedeniDurum = "bekar", Il = "Kastamonu", Ilce = "Tosya", Yas = 28 }); p.Add(new Personel { Id = 7, Ad = "engin", Soyad = "öztürk", KimlikNo = 489643456, MedeniDurum = "bekar", Il = "Bolu", Ilce = "Gerede", Yas = 19 }); p.Add(new Personel { Id = 8, Ad = "sefa", Soyad = "eker", KimlikNo = 453456489, MedeniDurum = "evli", Il = "Bilecik", Ilce = "Merkez", Yas = 49 }); p.Add(new Personel { Id = 9, Ad = "ahmet", Soyad = "başdan", KimlikNo = 345956456, MedeniDurum = "bekar", Il = "Ankara", Ilce = "Merkez", Yas = 53 }); #endregion return View(p.ToList()); } |
View
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
@using dataTableMVC.class_ @model List<Personel> @{ ViewBag.Title = "test"; Layout = null; } <link href="//cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css" rel="stylesheet" /> <div class="row"> <div class="col-lg-12"> <table id="myTable" class="display"> <thead> <tr> <th>#</th> <th>Ad</th> <th>Soyad</th> <th>KimlikNo</th> <th>MedeniDurum</th> <th>Yas</th> <th>Il</th> <th>Ilce</th> </tr> </thead> <tbody> @foreach (var item in Model) { <tr> <td>@item.Id</td> <td>@item.Ad</td> <td>@item.Soyad</td> <td>@item.KimlikNo</td> <td>@item.MedeniDurum</td> <td>@item.Yas</td> <td>@item.Il</td> <td>@item.Ilce</td> </tr> } </tbody> </table> </div> </div> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="//cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function () { $('#myTable').DataTable(); }); </script> |
Personel Class
1 2 3 4 5 6 7 8 9 10 11 |
public class Personel { public int Id { get; set; } public string Ad { get; set; } public string Soyad { get; set; } public int KimlikNo { get; set; } public string MedeniDurum { get; set; } public string Il { get; set; } public string Ilce { get; set; } public int Yas { get; set; } } |