mvc razor, alternating row style with bootstrap -sample


@{
    ViewBag.Title = "ÖĞRENCİLER";
}

<h2>@ViewBag.Title</h2>

<p>
  <a href="@Url.Action("Create" , "Student")"
class="btn btn-success"><i class="glyphicon glyphicon-plus-sign"></i> Yeni Öğrenci Kaydı</a>
</p>
@using (Html.BeginForm("Index", "Student", FormMethod.Get))
{
    <p class="alert-success">
        Ada Göre Kayıt Bul: @Html.TextBox("SearchString", ViewBag.CurrentFilter as string,
new { @class = "form-control" } )
  <button class="btn btn-default btn-md"><span class="glyphicon glyphicon-search"></span> Ara... </button>
    </p>
}
<table class="table table-striped"  >
<thead>
<tr>
<th>
@Html.ActionLink("Soyadı", "Index", new { sortOrder = ViewBag.NameSortParm, currentFilter = ViewBag.CurrentFilter })
</th>
<th>
Adı
</th>
<th>
@Html.ActionLink("Eğitim-Öğrenim Tarihi", "Index", new { sortOrder = ViewBag.DateSortParm, currentFilter = ViewBag.CurrentFilter })
</th>
<th>İşlem</th>
</tr>
</thead>
<tbody>
@{
var _SayfadakiKayitSayisi = 0;var _TumKayitlarinToplamSayisi = 0;
_TumKayitlarinToplamSayisi = Model.TotalItemCount;
}
    @foreach (var item in Model)
{
_SayfadakiKayitSayisi = _SayfadakiKayitSayisi + 1;
string rowColor = "pink";
if (_SayfadakiKayitSayisi % 2 == 0)
{
//rowColor = "yellow";
}
else{rowColor = "lightgray";}

<tr style="background-color:@rowColor;">
<td>
@Html.DisplayFor(modelItem => item.LastName)
</td>
<td>
@Html.DisplayFor(modelItem => item.FirstMidName)
</td>
<td>
@Html.DisplayFor(modelItem => item.EnrollmentDate)
</td>
<td>
<a href="@Url.Action("Edit" + "/" + item.ID , "Student")"
class="btn btn-primary"><i class="glyphicon glyphicon-edit"></i>Değiştir</a> |

<a href="@Url.Action("Details" + "/" + item.ID, "Student")"
class="btn btn-warning"><i class="glyphicon glyphicon-th-list"></i>Ayrıntılar</a> |

<a href="@Url.Action("Delete" + "/" + item.ID, "Student")"
class="btn btn-danger"><i class="glyphicon glyphicon-remove"></i>Sil</a>
</td>
</tr>
_SayfadakiKayitSayisi += 1;
}
</tbody>
</table>
<hr />
<div id="divKayitsayilari" class="alert-success">
Bu Sayfadaki Kayit Sayisi : ( <span class="badge"> @_SayfadakiKayitSayisi </span> ) .. <br />
Tüm Kayıtların Toplam Sayısı : ( <span class="badge"> @_TumKayitlarinToplamSayisi </span>  ) ...
</div>
<br />
Sayfa : @Model.PageNumber / @Model.PageCount

@Html.PagedListPager(Model, page => Url.Action("Index",
    new { page, sortOrder = ViewBag.CurrentSort, currentFilter = ViewBag.CurrentFilter }))

Yorumlar