Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1048737
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T16:30:21+00:00 2026-05-16T16:30:21+00:00

I have table containing data . In every row there is a checkbox plus

  • 0

I have table containing data . In every row there is a checkbox plus a checkbox to select all checkbox at the headers.
Upon checking this checkboxes,corresponoding rows are to be deleted from database table.Plus,on chiecking the checkbox at the header,all rows will be deleted from the database table.How can i achieve this asp.net mvc.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T16:30:21+00:00Added an answer on May 16, 2026 at 4:30 pm

    As always start with a model:

    public class ProductViewModel
    {
        public int Id { get; set; }
        public string Name { get; set; }
    }
    

    Then a controller:

    public class HomeController : Controller
    {
        // TODO: Fetch this from a repository
        private static List<ProductViewModel> _products = new List<ProductViewModel>
        {
            new ProductViewModel { Id = 1, Name = "Product 1" },
            new ProductViewModel { Id = 2, Name = "Product 2" },
            new ProductViewModel { Id = 3, Name = "Product 3" },
            new ProductViewModel { Id = 4, Name = "Product 4" },
            new ProductViewModel { Id = 5, Name = "Product 5" },
        };
    
        public ActionResult Index()
        {
            return View(_products);
        }
    
        [HttpPost]
        public ActionResult Delete(IEnumerable<int> productIdsToDelete)
        {
            // TODO: Perform the delete from a repository
            _products.RemoveAll(p => productIdsToDelete.Contains(p.Id));
            return RedirectToAction("index");
        }
    }
    

    And finally the Index.aspx view:

    <% using (Html.BeginForm("delete", "home", FormMethod.Post)) { %>
    
        <table>
            <thead>
                <tr>
                    <th>Name</th>
                    <th>Select</th>
                </tr>
            </thead>
            <tbody>
                <%= Html.EditorForModel()%>
            </tbody>
        </table>
    
        <input type="submit" value="Delete selected products" />
    
    <% } %>
    

    And the product editor template (~/Views/Home/EditorTemplates/ProductViewModel.ascx):

    <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ToDD.Controllers.ProductViewModel>" %>
    <tr>
        <td>
            <%: Model.Name %>
        </td>
        <td>
            <input type="checkbox" name="productIdsToDelete" value="<%: Model.Id %>" />
        </td>
    </tr>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table containing hierarchical data. There are currently ~8 levels in this
I have a table containing data about some users. Many of them use our
Let's say I have a table containing following data: | id | t0 |
I have data table containing one column as FilePath. FilePath D:\New folder\link.txt D:\New folder\SharepointMigration(Work
Ok I have a data table containing duplicate Reciept numbers and a transaction value
I have a db table containing a column display_order . The data looks like
I have a data table. Each row of the table has a commandButton called
Consider a table invoice_data containing data about invoices over 12 years. This data will
I have a number of tables containing some basic (business related) mapping data. What's
I have a small database with tables containing a small amount of data which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.