c# - 如何在 asp.net-mvc 中添加 actionlink?
问题描述
我试图将 actionlink 添加到我的代码中,但是。我无法产生正确的看法。
table class="table table-bordered table-striped table">
<thead>
<tr>
@foreach (System.Data.DataColumn col in Model.Columns)
{
<th>@col.Caption</th>
}
</tr>
</thead>
<tbody>
@foreach (System.Data.DataRow row in Model.Rows)
{
<tr>
@foreach (var cell in row.ItemArray)
{
<td>@cell.ToString()</td>
}
</tr>
<tr>
@foreach (var cell in row.ItemArray)
{
<td>@Html.ActionLink("Click for rent this car", "IntoSaleTable")</td>
}
</tr>
}
}
</tbody>
由于上述代码 1
我的代码为单行生成多个操作链接,但我每行只需要一个操作链接。
解决方案
根据您的评论,试试这个:
<table class="table table-bordered table-striped table">
<thead>
<tr>
@foreach (System.Data.DataColumn col in Model.Columns)
{
<th>@col.Caption</th>
}
<th></th>
</tr>
</thead>
<tbody>
@foreach (System.Data.DataRow row in Model.Rows)
{
<tr>
@foreach (var cell in row.ItemArray)
{
<td>@cell.ToString()</td>
}
<td>@Html.ActionLink("Click for rent this car", "IntoSaleTable")</td> <!-- use row["Id"] to pass Id or somethig-->
</tr>
}
</tbody>
</table>
推荐阅读
- r - 我需要从数据框列表中按名称提取 Excel 工作表,其中每一行都是工作表的名称
- r - 使用基本样本生成随机数时排除 0
- python - python import 命令返回“no-module-named...”,但该模块显然在站点包中?
- php - PHP & MySQL DateTime - 时区处理
- java - Java Enum 将类嵌入到字段中
- java - 无法从反应方法传播错误
- html - 如何让 IE 不切断弹出菜单?
- c++ - 为什么我们需要引用成员的复制构造函数
- azure - 如何从 Azure Batch 访问 Azure 数据库?
- json - 无法使用 Alamofire 解析 json