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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T22:24:57+00:00 2026-05-20T22:24:57+00:00

My view displays a series of rows in an html table. The rows are

  • 0

My view displays a series of rows in an html table. The rows are ordered by a rank order from the database. One of the columns in the html table is a textbox that will allow the user to modify this rank order. There is an Update submit button at the bottom of the table which will allow the user to save this new order. The problem Im encountering is that the rank order is updated correctly to the database, but when the controller returns back to the view, all data is updated correctly on the screen but the values in the text box are not updated.

Order   |  Data     
================================================
10      |  Item 1
20      |  Item 2
30      |  Item 3

Lets say the user makes the following changes
Order   |  Data
================================================
50      |  Item 1
20      |  Item 2
10      |  Item 3

Now User hits update and what is rendered is:

Order   |  Data
================================================
50      |  Item 3
20      |  Item 2
10      |  Item 1

(Note data was sorted correctly but values of TextBoxFor did not update)

My View Code

@using (Html.BeginForm("UpdateRanks", "MyController")) {
    <table cellpadding="0" cellspacing="0" width="100%">
    @for (int i = 0; i < Model.DbSelections.Count; i++) {
       var item = Model.DbSelections[i];
       <tr>
        <td>
            @Html.TextBoxFor(m => m.DbSelections[i].Rank, new { @class = "NarrowTextBox" })
        </td>
        <td>
            @Model.DbSelections[i].Rank (works!), @item.ItemName<br />
        </td>
       </tr>
    }
    <input type="submit" value="Update" name="updateaction"  class="StandardButton"/>
</table>
}

Controller code:

[HttpPost]
[MultiButton(MatchFormKey = "updateaction", MatchFormValue = "Update")]
public ActionResult UpdateRanks(MyViewModel model) {

    if (ModelState.IsValid) {

        MyRepository myRepo = new MyRepository();
        <!-- saves updated ranks to database - it works -->
        myRepo.UpdateAutoPicks(...);

        <!-- after saved ranks above, now reload data including ranks from database -->
        <!-- debugging shows that data and ranks and ordering is correct->
        model.DbSelections = myRepo.GetItems();

        return View("Index", model);


    } else {
        <!-- blah -->
    }

    return View("Index", model);
}
  • 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-20T22:24:57+00:00Added an answer on May 20, 2026 at 10:24 pm

    See if this other Post helps you out.

    The one caveat with using this solution is that you’ll lose any of the built in features of using TextBoxFor(), such as validation. If this doesn’t work you can try doing ModelState.Clear() to clear out the posted values (see here for more details).

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

Sidebar

Related Questions

I have a view that displays a table: rows represent days - one row
I have an action 'approval' that renders a view which displays some content from
I have a list view that displays a collection of items, each item has
I have a Drupal view that displays vacation leaves for a particular employee. I
I have a WPF view that displays a Shipment entity. I have a textblock
I have created a list view that displays the names and dates of items
So i'm making a custom View that displays some graphs (plots), and in some
In an iPhone application I'm developing I have a Image View that displays eyes
My first view displays an image and action indicator while web-servers and database function
I have a standard UINavigationController setup. One particular view displays an Edit button on

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.