asp.net mvc批量删除的实现
<form action="Index" method="post">
<div>
@{
<table>
<thead>
<tr>
<th width="100">
编号
</th>
<th width="100">
名字
</th>
</tr>
</thead>
<tbody>
foreach (var item in Model)
{
<tr >
<td><input type="checkbox" value="@item.id" name="checkedId"/></td>
<td>@item.Name</td>
</tr>
}
</tbody>
</table>
}</div>
<div>
<input type="submit" value="删除"/>
</div>
</form>
#region 批量删除
[Authorize]
[HttpPost]
public ActionResult Index(string[] checkedId)
{
if (checkedId != null)
{
string strIds = string.Join(",", checkedId.Cast<string>().ToArray());
DAL.BatchDelete(strIds)
return View();
}
}