如何删除联系人列表中的多个选定联系人列表 [英] How do I Delete multiple selected List of contact in Contact List
本文介绍了如何删除联系人列表中的多个选定联系人列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
//
// POST: /ManageContact/Delete/5
[HttpPost]
public ActionResult Delete(ContactsViewModel model)
{
var contact = _contactService.GetContactById(model.Id);
if (contact == null)
return View();
var idArray = new[] { model.Id };
_contactService.RemoveContact(idArray);
return RedirectToAction("Index");
}
这是接触控制器
this the contact controller
@using (Html.BeginForm())
{
<div>
<h4 class="center">Available Contact(s)</h4><br /><div>
@Html.AntiForgeryToken()
</div>
</div><div class="span12"></div>
<div class=" btn-group">
<input class="btn btn-info " type="submit" value=" Send Message"><input class="btn btn-info " type="submit" value=" Add to Group"><input class="btn btn-info " type="submit" value=" Delete Contacts">
</div>
}
<div class="span11 blog-item ">
<div class="row-fluid">
<div class="span12">
<table class="table table-striped table-hover table-bordered">
<thead>
<tr>
<th></th>
<th><h4 class="center">Contact Name(s)</h4></th>
<th><h4 class="center">Mobile Number(s)</h4></th>
<th><h4 class="center">Actions</h4></th>
</tr>
</thead>
@foreach (var item in Model)
{
<tbody>
<tr>
<td><input type="checkbox" value="@item.Id" name="deleteInputs"></td>
<td>
@Html.DisplayFor(modelItem => item.Name, new { @class = "center" })
</td>
<td>
@Html.DisplayFor(modelItem => item.MobileNumber, new { @class = "center" })
</td>
<td>
<a data-toggle="modal" href="#loginForm">Add To Group</a>
@*@Html.ActionLink("Add to Group", "AddtoGroup", new { }, new { @class = "center", })*@ |
@Html.ActionLink("Edit", "Edit", new { id = item.Id }, new { @class = "center" }) |
@Html.ActionLink("Delete", "Delete", new { id = item.Id })
</td>
</tr>
</tbody>
}
</table>
这是显示表中每个联系人的视图...
因此,请问如何使用复选框选择多个联系人并使用控制器中的按钮进行删除,并使用带有存储库的服务
And this is the view that display every contacts in a table...
So please how do i go about selecting multiple contact using the checkbox and delete with the button in my controller and am using Services with Repository
推荐答案
希望这会有所帮助
http://aspsolutionkirit.blogspot.in/2013/09/mvc- example-for-delete-multiple-record.html [ ^ ]
hope this helps
http://aspsolutionkirit.blogspot.in/2013/09/mvc-example-for-delete-multiple-record.html[^]
这篇关于如何删除联系人列表中的多个选定联系人列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文