Click here to Skip to main content
14,422,431 members
Rate this:
Please Sign up or sign in to vote.
See more:
        // POST: /ManageContact/Delete/5
        public ActionResult Delete(ContactsViewModel model)
            var contact = _contactService.GetContactById(model.Id);

            if (contact == null)
                return View();

            var idArray = new[] { model.Id };

            return RedirectToAction("Index");

this the contact controller

@using (Html.BeginForm())
                <h4 class="center">Available Contact(s)</h4><br /><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 class="span11 blog-item ">
            <div class="row-fluid">
                <div class="span12">
                    <table class="table table-striped table-hover table-bordered">
                                <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>
                        @foreach (var item in Model)
                                    <td><input type="checkbox" value="@item.Id" name="deleteInputs"></td>
                                        @Html.DisplayFor(modelItem => item.Name, new { @class = "center" })
                                        @Html.DisplayFor(modelItem => item.MobileNumber, new { @class = "center" })
                                        <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 })


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

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

Member 10765778 23-May-14 8:07am
yea i get that thanks but there is still a little problem...
how do i assign (var idArray = new[] { model.Id };) to ( var chckedValues = form.GetValues("assignChkBx");)
Ayan Chalki 26-May-14 7:26am
In my example "webGrid" is used not "table tr td". And in that webgrid, "assignChkBx" column is added with value="@item.Id". so replace var idArray = new[] { model.Id }; with var idArray = form.GetValues("assignChkBx");). Do you get it what I said?
Member 10765778 27-May-14 4:31am
oka it help Tanks very mush

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100