Skip to content

Commit b5d560d

Browse files
committed
8. Adding Search
1 parent 4233cdd commit b5d560d

File tree

3 files changed

+48
-42
lines changed

3 files changed

+48
-42
lines changed

MvcMovie/App_Data/Movies.mdf

0 Bytes
Binary file not shown.

MvcMovie/App_Data/Movies_log.ldf

0 Bytes
Binary file not shown.

MvcMovie/Views/Movies/Index.cshtml

+48-42
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,57 @@
11
@model IEnumerable<MvcMovie.Models.Movie>
2-
32
@{
43
ViewBag.Title = "Index";
54
}
6-
75
<h2>Index</h2>
8-
96
<p>
107
@Html.ActionLink("Create New", "Create")
11-
</p>
12-
<table class="table">
13-
<tr>
14-
<th>
15-
@Html.DisplayNameFor(model => model.Title)
16-
</th>
17-
<th>
18-
@Html.DisplayNameFor(model => model.ReleaseDate)
19-
</th>
20-
<th>
21-
@Html.DisplayNameFor(model => model.Genre)
22-
</th>
23-
<th>
24-
@Html.DisplayNameFor(model => model.Price)
25-
</th>
26-
<th></th>
27-
</tr>
8+
@using (Html.BeginForm("Index", "Movies", FormMethod.Get))
9+
{
10+
<p>
11+
Genre: @Html.DropDownList("movieGenre", "All")
12+
Title: @Html.TextBox("SearchString")
13+
<input type="submit" value="Filter" />
14+
</p>
15+
}
16+
</p>
17+
<table class="table">
18+
<tr>
19+
<th>
20+
@Html.DisplayNameFor(model => model.Title)
21+
</th>
22+
<th>
23+
@Html.DisplayNameFor(model => model.ReleaseDate)
24+
</th>
25+
<th>
26+
@Html.DisplayNameFor(model => model.Genre)
27+
</th>
28+
<th>
29+
@Html.DisplayNameFor(model => model.Price)
30+
</th>
31+
<th></th>
32+
</tr>
2833

29-
@foreach (var item in Model) {
30-
<tr>
31-
<td>
32-
@Html.DisplayFor(modelItem => item.Title)
33-
</td>
34-
<td>
35-
@Html.DisplayFor(modelItem => item.ReleaseDate)
36-
</td>
37-
<td>
38-
@Html.DisplayFor(modelItem => item.Genre)
39-
</td>
40-
<td>
41-
@Html.DisplayFor(modelItem => item.Price)
42-
</td>
43-
<td>
44-
@Html.ActionLink("Edit", "Edit", new { id=item.ID }) |
45-
@Html.ActionLink("Details", "Details", new { id=item.ID }) |
46-
@Html.ActionLink("Delete", "Delete", new { id=item.ID })
47-
</td>
48-
</tr>
49-
}
34+
@foreach (var item in Model)
35+
{
36+
<tr>
37+
<td>
38+
@Html.DisplayFor(modelItem => item.Title)
39+
</td>
40+
<td>
41+
@Html.DisplayFor(modelItem => item.ReleaseDate)
42+
</td>
43+
<td>
44+
@Html.DisplayFor(modelItem => item.Genre)
45+
</td>
46+
<td>
47+
@Html.DisplayFor(modelItem => item.Price)
48+
</td>
49+
<td>
50+
@Html.ActionLink("Edit", "Edit", new { id = item.ID }) |
51+
@Html.ActionLink("Details", "Details", new { id = item.ID }) |
52+
@Html.ActionLink("Delete", "Delete", new { id = item.ID })
53+
</td>
54+
</tr>
55+
}
5056

51-
</table>
57+
</table>

0 commit comments

Comments
 (0)