How to delete multiple webgrid rows by using Checkboxes in asp.net MVC 4 Application.

WebGrid is an most popular helper (control) for display data in mvc application. We also used this control to allow user perform CRUD operations in many occasions, like In a typical scenario, user click on edit link of any row and go to edit page for update the data of this seleted row.But, what if we want to delete multiple rows at once. Here I going to explain how to get back selected rows from webgrid at the server side for perform operation like bulk delete.
Multiple Delete from Webgrid
Select Customer ID Customer Name Address City Postal Code
1 Jonny Decosta Obere Str. 57 London 5466
2 Suresh Das A/17 Khandala Canada D.A 2455
3 Satish Roy Mataderos 2312 Simla 1245
4 Mr. S. K. Almer 120 bengira Rd. Singapur 1478
5 Benji Dutta 56 chouringi hill Dubai 1456
6 Maria Anders Obere Str. 57 Berlin 98401
7 Ana Trujillo Avda. de la Constitución 2222 México D.F. 98033
8 Antonio Moreno Mataderos 2312 México D.F. 98052
9 Thomas Hardy 120 Hanover Sq. London SW1 8JR
10 Hanna Moos Forsterstr. 57 Mannheim SW1 8JR
11 Robert King Berguvsvägen 8 Mannheim WG2 7LT


How to delete multiple webgrid rows by using Checkboxes in asp.net MVC 4 Application.
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8" />
        <title>@ViewBag.Title - My ASP.NET MVC Application</title>
        <link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />
        <meta name="viewport" content="width=device-width" />
        @Styles.Render("~/Content/css")
        @Scripts.Render("~/bundles/modernizr")
    </head>
    <body>
        <header>
            <div class="content-wrapper">
                <div class="float-left">
                    <p class="site-title">@Html.ActionLink("your logo here", "Index", "Home")</p>
                </div>
                <div class="float-right">
                    <section id="login">
                        @Html.Partial("_LoginPartial")
                    </section>
                    <nav>
                        <ul id="menu">
                            <li>@Html.ActionLink("Home", "Index", "Home")</li>
                            <li>@Html.ActionLink("About", "About", "Home")</li>
                            <li>@Html.ActionLink("Contact", "Contact", "Home")</li>
                        </ul>
                    </nav>
                </div>
            </div>
        </header>
        <div id="body">
            @RenderSection("featured", required: false)
            <section class="content-wrapper main-content clear-fix">
                @RenderBody()
            </section>
        </div>
        <footer>
            <div class="content-wrapper">
                <div class="float-left">
                    <p>&copy; @DateTime.Now.Year - My ASP.NET MVC Application</p>
                </div>
            </div>
        </footer>

        @Scripts.Render("~/bundles/jquery")
        @RenderSection("scripts", required: false)
    </body>
</html>


 
Posted By :