我只想动态地向我的表添加两列。使用mvc razor ..这是我的代码: -
<table>
<tr>
<th>id</th>
<th>name</th>
<th>type</th>
<th>delete</th>
<th>modified</th>
and for getting data to my table m using code like :-
<tbody>
@foreach (System.Data.DataRow row in Model.Rows )
{
<tr>
@foreach (var in cell in row.ItemArray)
{
if (cell ! = null)
{
<td>@cell.ToString()</td>
}
else {
<td></td>
}
}
</tr>
}
<tbody>
</table>
现在我只是想在每行的删除和修改列中添加一个链接..感谢您的帮助
答案 0 :(得分:1)
您可以在单元格循环后在列中添加按钮。我也很高兴你使用PartialView进行按钮显示,但这取决于你。以下是这样做的简单方法。我还使用了一些bootstrap类。
<tbody>
@foreach (System.Data.DataRow row in Model.Rows )
{
<tr>
@foreach (var in cell in row.ItemArray)
{
if (cell ! = null)
{
<td>@cell.ToString()</td>
}
else {
<td></td>
}
}
<td>
<a class="btn btn-primary btn-sm" href="@Url.Action("Edit", "ABC", new { id=Model.Id})" title="Edit ABC"><i class="glyphicon glyphicon-edit"></i></a></td>
<td>
<a class="btn btn-info btn-sm" href="@Url.Action("Details", "ABC", new { id=Model.Id })" title="Details of ABC"><i class="glyphicon glyphicon-file"></i></a></td>
<td>
<a class="btn btn-danger btn-sm" href="@Url.Action("Delete", "ABC", new { id=Model.Id })" title="Delete this ABC"><i class="glyphicon glyphicon-remove"></i></a></td>
</tr>
}
</tbody>
答案 1 :(得分:0)
在内循环后添加更多单元格:
sh: C:/Git/mingw64/bin/git-upload-pack: No such file or directory.