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 7512033
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T23:44:24+00:00 2026-05-29T23:44:24+00:00

I want the user to update multiple rows at once so I created a

  • 0

I want the user to update multiple rows at once so I created a form like this (I stripped out the HTML to show what I really mean):

@using(Html.BeginForm()) {

    @{int i = 0; }
    @foreach(var row in Model) {
        @Html.TextBox("Customer["+ i +"].CustomerID")
        @Html.TextBox("Customer["+ i +"].Name")
    }

    <input type="submit" />
}

The output in HTML is (for 3 rows):

<input type="text" name="Customer[0].CustomerID" />
<input type="text" name="Customer[0].Name" />

<input type="text" name="Customer[1].CustomerID" />
<input type="text" name="Customer[1].Name" />

<input type="text" name="Customer[2].CustomerID" />
<input type="text" name="Customer[2].Name" />

When the user clicks the submit button, the data is sent to a Controller:

Public ActionResult EditCustomer(IEnumerable<Customer> Customer) {
}

Which gives me a nice IEnumerable with all the entered data and I can do whatever I want. It works as expected.

Now I’d like to take it one step further and allow the user to remove rows.

This fails

Because when I remove the second row, the array is no longer ‘closed’: it goes from Customer[0] to Customer[2] and ASP.NET MVC has problems with that.

So I think that can be solved with recalculating the indexes. But how do I do this in jQuery?

So that after the middle row has been deleted a function is run that updates Customer[2].CustomerID to Customer[1].CustomerID.

  • 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-29T23:44:26+00:00Added an answer on May 29, 2026 at 11:44 pm

    I would recommend you the following article which illustrates a nice helper that you could use for achieving that instead of using magic strings.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using DataTables . I want to let the user select multiple rows and
So I have a form that I want the user to use to update
I want to update a list of storage devices as the user inserts USB
I have an index view that I want to update automatically as the user
User Region Points Last_Updated 1 5 0 1-Nov-09 I want this row 2 1
I want the user to be able to make some preferences like colors, prefered
I have created a set of templates that I want to share across multiple
In a Windows Form window, multiple events can trigger an asynchronous method. This method
I want to implement a Facebook updates(user action and notifications) on my web application
I want user to type some text in JTextField and it must match some

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.