11.1.3 Implementing the List View; Listing 11-4 Modifying the Index.cshtml View
This commit is contained in:
parent
6801b717df
commit
8c22c6e26a
@ -9,26 +9,39 @@
|
||||
<p>
|
||||
@Html.ActionLink("Create New", "Create")
|
||||
</p>
|
||||
<table class="table">
|
||||
<tr>
|
||||
<th>@Html.DisplayNameFor(model => model.Name)</th>
|
||||
<th>@Html.DisplayNameFor(model => model.Description)</th>
|
||||
<th>@Html.DisplayNameFor(model => model.Price)</th>
|
||||
<th>@Html.DisplayNameFor(model => model.Category)</th>
|
||||
</tr>
|
||||
|
||||
@foreach (var item in Model)
|
||||
{
|
||||
<tr>
|
||||
<td>@Html.DisplayFor(modelItem => item.Name)</td>
|
||||
<td>@Html.DisplayFor(modelItem => item.Description)</td>
|
||||
<td>@Html.DisplayFor(modelItem => item.Price)</td>
|
||||
<td>@Html.DisplayFor(modelItem => item.Category)</td>
|
||||
<td>
|
||||
@Html.ActionLink("Edit", "Edit", new { id=item.ProductID }) |
|
||||
@Html.ActionLink("Details", "Details", new { id=item.ProductID }) |
|
||||
@Html.ActionLink("Delete", "Delete", new { id=item.ProductID})
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</table>
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h3>All Products</h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<table class="table table-striped table-condensed table-bordered">
|
||||
<tr>
|
||||
<th class="text-right">ID</th>
|
||||
<th>Name</th>
|
||||
<th class="text-right">Price</th>
|
||||
<th class="text-center">Actions</th>
|
||||
</tr>
|
||||
@foreach (var item in Model)
|
||||
{
|
||||
<tr>
|
||||
<td class="text-right">@item.ProductID</td>
|
||||
<td>@Html.ActionLink(item.Name, "Edit", new { item.ProductID })</td>
|
||||
<td class="text-right">@item.Price.ToString("c")</td>
|
||||
<td class="text-center">
|
||||
@using (Html.BeginForm("Delete", "Admin"))
|
||||
{
|
||||
@Html.Hidden("ProductID", item.ProductID)
|
||||
<input type="submit"
|
||||
class="btn btn-default btn-xs"
|
||||
value="Delete" />
|
||||
}
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</table>
|
||||
</div>
|
||||
<div class="panel-footer">
|
||||
@Html.ActionLink("Add a new product", "Create", null, new { @class = "btn btn-default" })
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user