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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:48:04+00:00 2026-05-20T10:48:04+00:00

I have a strongly-typed view, with a list of custom objects in the model.

  • 0

I have a strongly-typed view, with a list of custom objects in the model.

In the view I display textboxes for every object in the list :

@using (Html.BeginForm("SaveData", "Localization", FormMethod.Post))
{
        foreach (YB.LocalizationGlobalText m in Model.GlobalTexts)
    { 
            @Html.Label(m.LocalizationGlobal.Name)
            @Html.TextBoxFor(model => m.Text)
            <br />
    }   
    <input type="submit" value="Save" />
}

Now how would I get the updated data from the textboxes in my model.
I can see in the formcollection the updated data is there:

    [HttpPost]
    public virtual ActionResult SaveData(FormCollection form)
    {
        // Get movie to update
        return View();
   }

form[“m.Text”] = “testnewdata1,testnewdata”

But how do I get this mapped to the model, so I have the updated values for each object.
Or how can I get it cleanly from the formcollection, something like this .. form[someid][“m.Text”]

Edit:

I also tried passing the model as a parameter, but the model data is empty.

[HttpPost]
        public virtual ActionResult SaveData(LocalizationModel model, FormCollection form)
        {
            // Get movie to update
            return View();
       }

When I look into the model: model.GlobalTexts = null

  • 1 1 Answer
  • 1 View
  • 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-20T10:48:05+00:00Added an answer on May 20, 2026 at 10:48 am
    [HttpPost]
    public virtual ActionResult SaveData(int movieId, FormCollection form)
    {
        // Get movie to update
        Movie movie = db.Movies.Where(x => x.Id == movieId);
        // Update movie object with values from form collection.
        TryUpdateModel(movie, form);
        // Do model validation
        if (!ModelState.IsValid)
            return View();
        return View("success");
    }
    

    Edit See this question I asked a while back: How to use multiple form elements in ASP.NET MVC

    Lets say you have a view like this:

    @model IEnumerable<CustomObject>
    
    @foreach (CustomObject customObject in Model)
    {
        <div>
            @Html.TextBox(customObject.CustomProperty);
            <!-- etc etc etc -->
        </div>
    }
    

    Refactor it like this:

    @model IEnumerable<CustomObject>
    
        @for (int count = 0; count < Model.Count(); count++)
        {
            <div>
                <!-- Add a place for the id to be stored. -->
                @Html.HiddenFor(x => x[count].Id);
    
                @Html.TextBoxFor(x => x[count].CustomProperty);
                <!-- etc etc etc -->
            </div>
        }
    

    Now in your action method do this:

    public virtual ActionResult SaveData(IEnumerable<CustomObject>)
    {
        // You now have a list of custom objects with their IDs intact.
    }
    

    It’s even easier than that if you use editors, but I’ll let you figure those out for yourself as they are super simple. The accepted answer in the question I linked shows an example.

    NOTE: you can substitute IList for IEnumerable if you need to.

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

Sidebar

Related Questions

i have a strongly typed asp.net-mvc view and the Model has a . Links
I have an strongly typed view for my model and what I'd like is
i have an strongly typed object that represents all of the textbox properties of
I have a System.Web.Mvc.RazorView object which is strongly typed when in cshtml. Can I
I have a datagrid who's ItemsSource is a strongly typed IEnumerable object In this
I have a strongly typed view of type ProductListingViewModel which in turn contains a
I have a strongly typed partial view CheckBox.ascx that renders a checkbox. This is
I have a partial view that renders a list of objects into a table
Keywords: asp.net mvc 3, checkbox list, strongly typed view. So, please don't suggest me
i'm trying to create a strongly-typed view using Visual Studio 2008. I can right-click

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.