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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T23:47:04+00:00 2026-06-06T23:47:04+00:00

I have problem, that the text box value doesn’t get updated with the new

  • 0

I have problem, that the text box value doesn’t get updated with the new value in the model.
@Html.TextBoxFor(m => m.MvcGridModel.Rows[j].Id)

First the collection MvcGridModel.Rows get populated with some data, then when press button and submit the form it get new data successfully, but it doesn’t update the textbox’s value.

Do you have any ideas?
Thank u in advance

  • 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-06-06T23:47:05+00:00Added an answer on June 6, 2026 at 11:47 pm

    That’s because HTML helpers such as TextBoxFor first look in the ModelState when binding their values and only after that in the model. So if in your POST action you attempt to modify some value that was part of the initial POST request you will have to remove it from the ModelState as well if you want those changes to take effect in the view.

    For example:

    [HttpPost]
    public ActionResult Foo(MyViewModel model)
    {
        // we change the value that was initially posted
        model.MvcGridModel.Rows[0].Id = 56;
    
        // we must also remove it from the ModelState if
        // we want this change to be reflected in the view
        ModelState.Remove("MvcGridModel.Rows[0].Id");
    
        return View(model);
    }
    

    This behavior is intentional and it is by design. This is what allows for example to have the following POST action:

    [HttpPost]
    public ActionResult Foo(MyViewModel model)
    {
        // Notice how we are not passing any model at all to the view
        return View();
    }
    

    and yet inside the view you get the values that the user initially entered in the input fields.

    There’s also the ModelState.Clear(); method that you could use to remove all keys from the modelstate but be careful because this also removes any associated modelstate errors, so it is recommended to remove only values from the ModelState that you intend to modify inside your POST controller action.

    All this being said, in a properly designed application you should not need this. Because you should use the PRG pattern:

    [HttpPost]
    public ActionResult Index(MyViewModel model)
    {
        if (!ModelState.IsValid)
        {
            // there was some error => redisplay the view without any modifications
            // so that the user can fix his errors
            return View(model);
        }
    
        // at this stage we know that the model is valid. 
        // We could now pass it to the DAL layer for processing.
        ...
    
        // after the processing completes successfully we redirect to the GET action
        // which in turn will fetch the modifications from the DAL layer and render
        // the corresponding view with the updated values.
        return RedirectToAction("Index");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a big problem. I want to extract text from html table that
I have a textbox that gets a decimal value say 10500.00 the problem is
I am loading some text dynamically into a div, but have the problem that
i have large numbers of text files and i am in problem that i
I have the following problem with Tikz/Latex: I have some nodes that contain text.
I'm having a strange problem in that I have php inserting text into a
I have a simple control that has a masked text box: xmlns:extToolkit=http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended ... <extToolkit:MaskedTextBox
the problem is that I do have an ASP.NET TextBox in a FormView with
In a couple of scripts that I use I have problem that is intermittent.
I have a problem that I'm working on for quite some time now. I

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.