码迷,mamicode.com
首页 > Web开发 > 详细

MVC4.0实现批量删除

时间:2017-11-24 15:01:10      阅读:213      评论:0      收藏:0      [点我收藏+]

标签:pos   mvc4.0   app   checkbox   put   todo   http   lin   cat   

HTML代码:

@using(Html.BeginForm("Delete","Home")){
<div>
<input type="submit" value="删除" class="delete" onclick="return confirm(‘确定要删除吗?‘)"/>
</div>
<table>
<tr>
<th>@Html.CheckBox("chackall")</th>
<th>标题</th>
<th>操作</th>
</tr>
<tr>
<td>@Html.CheckBox("checkid",new{ value="1"})</td>
<td>数据1</td>
<td>@Html.ActionLink("详细","Details",new{ id="1"})</td>
</tr>
<tr>
<td>@Html.CheckBox("checkid",new{ value="2"})</td>
<td>数据2</td>
<td>@Html.ActionLink("详细","Details",new{ id="2"})</td>
</tr>
<tr>
<td>@Html.CheckBox("checkid",new{ value="3"})</td>
<td>数据3</td>
<td>@Html.ActionLink("详细","Details",new{ id="3"})</td>
</tr>
<tr>
<td>@Html.CheckBox("checkid",new{ value="4"})</td>
<td>数据4</td>
<td>@Html.ActionLink("详细","Details",new{ id="4"})</td>
</tr>
<tr>
<td>@Html.CheckBox("checkid",new{ value="5"})</td>
<td>数据5</td>
<td>@Html.ActionLink("详细","Details",new{ id="5"})</td>
</tr>
</table>
}

 

action代码:

 


[HttpPost] public ActionResult Delete(List<string> checkid) {

ApplicationContext db=new ApplicationContext();

try {

// TODO: Add delete logic here db.RemoveAll(m => checkid.Contains(m.id)); db.SaveChanges(); return RedirectToAction("Index");

}

catch { return View();

}

}


来自:http://www.cnblogs.com/sky-net/p/4415697.html

 

MVC4.0实现批量删除

标签:pos   mvc4.0   app   checkbox   put   todo   http   lin   cat   

原文地址:http://www.cnblogs.com/mz917520857/p/7890298.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!