参考asp.net MVC教程: http ://www.asp.net/mvc/tutorials/getting-started-with-aspnet-mvc3/cs/examineing-the-edit-methods-and-edit-view
关于自动生成的 Views\Movies\SearchIndex.cshtml
问题一:
<p>
@Html.ActionLink("Create New", "Create")
@using (Html.BeginForm())
{
<p>
Genre: @Html.DropDownList("movieGenre", "All")
Title: @Html.TextBox("SearchString", "Movies", FormMethod.Get)
<input type="submit" value="Filter" />
</p>
}
</p>
movieGenre是如何引用@ViewBag.movieGenre的,这显然是在 Controllers/MoviesController.cs 中定义的
问题2:
@foreach (var item in Model) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.Title)
</td>
<td>
@Html.DisplayFor(modelItem => item.ReleaseDate)
</td>
<td>
@Html.DisplayFor(modelItem => item.Genre)
</td>
<td>
@Html.DisplayFor(modelItem => item.Price)
</td>
<td>
@Html.ActionLink("Edit", "Edit", new { id=item.ID }) |
@Html.ActionLink("Details", "Details", new { id=item.ID }) |
@Html.ActionLink("Delete", "Delete", new { id=item.ID })
</td>
</tr>
}
modelItem在哪里定义?VS2010 向我展示了 modelItem 是
IEnumerable <MvcMovie.Model.Movie>
谢谢。