Pez*_*aee 5 asp.net-mvc html.actionlink razor
在asp.net mvc中,我有一个带有名称索引的视图,它将一个html表显示为网格.假设这是我的html表:
<table>
<tr>
<th>
Caption
</th>
<th></th>
</tr>
@foreach (var item in Model) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.Caption)
</td>
<td>
@Html.ActionLink("Edit", "Edit", new { id=item.CityId }) |
@Html.ActionLink("Details", "Details", new { id=item.CityId }) |
@Html.ActionLink("Delete", "Delete", new { id=item.CityId }) |
</td>
</tr>
}
</table>
Run Code Online (Sandbox Code Playgroud)
现在我想把它放在@Html.DisplayFor(modelItem => item.Caption)文本中@Html.ActionLink("Edit", "Edit", new { id=item.CityId })
但我从mvc给出一个错误.
只需使用正确的方法重载,如下所示:
@Html.ActionLink(item.Caption, "Edit", "Edit", new { id=item.CityId }, null)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4139 次 |
| 最近记录: |