我正在学习 MVC
https://www.youtube.com/watch?v=ItSA19x4RU0&list=PL6n9fhu94yhVm6S8I2xd6nYz2ZORd7X2v
我正在做基本编辑操作..索引页面显示以下数据..
Emp_id Emp_name Emp_Sal
1 name1 sal1 Edit | Details | Delete
...当我点击 Edit ..URL Display Like
"http://localhost/MvcApplication1/Employee/Edit"`
...但是根据教程应该是这样的
http://localhost/MvcApplication1/Employee/Edit/01
地图路线是
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
到目前为止,我还没有创建 Edit ActionMethod。
索引视图代码是:
@model IEnumerable<BusinessLayer.Employee>
@{
ViewBag.Title = "Index";
}
<h2>
Index</h2>
<p>
@Html.ActionLink("Create New", "Create")
</p>
<table>
<tr>
<th>
@Html.DisplayNameFor(model => model.Emp_id)
</th>
<th>
@Html.DisplayNameFor(model => model.Emp_name)
</th>
<th>
@Html.DisplayNameFor(model => model.Emp_Sal)
</th>
<th>
</th>
</tr>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.Emp_id)
</td>
<td>
@Html.DisplayFor(modelItem => item.Emp_name)
</td>
<td>
@Html.DisplayFor(modelItem => item.Emp_Sal)
</td>
<td>
@Html.ActionLink("Edit", "Edit", new { /* id=item.PrimaryKey */ }) |
@Html.ActionLink("Details", "Details", new { /* id=item.PrimaryKey */ }) |
@Html.ActionLink("Delete", "Delete", new { /* id=item.PrimaryKey */ })
</td>
</tr>
}
</table>
请建议我是否遗漏了什么