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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T01:58:55+00:00 2026-05-20T01:58:55+00:00

I am trying to make an editor for an object in ASP.net MVC 3.

  • 0

I am trying to make an editor for an object in ASP.net MVC 3. It looks something like this:

<div class="editor-label">
    @Html.LabelFor(model => model.Name)
</div>
<div class="editor-field">
    @Html.EditorFor(model => model.Name)
    @Html.ValidationMessageFor(model => model.Name)
</div>
<div class="editor-label">
    @Html.LabelFor(model => model.foo)
</div>
<div class="editor-field">
    @Html.EditorFor(model => model.foo)
    @Html.ValidationMessageFor(model => model.foo)
</div>
@if (Model.Items.Count > 0)
{
<table>          
    @foreach (var ii in Model.Items)
    { @Html.EditorFor(item => ii) }
</table>
}

In this example, Items is a list of another kind of object. The problem is, when the model is posted back from being edited in the view, the data changes to Model.Items aren’t there, while the data changes to Name and foo work. How can I make it so that the data for Items binds correctly?

  • 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-20T01:58:56+00:00Added an answer on May 20, 2026 at 1:58 am

    Model class:

    public class HomeControllerModel
    {
        public string Name { get; set; }
        public string foo { get; set; }
        public List<string> Items { get; set; }
    
        public HomeControllerModel()
        {
            Items = new List<string>();
        }
    }
    

    Controller class:

    public class HomeController : Controller
    {
    
    
        [HttpGet]
        public ActionResult Index()
        {
            var model = new HomeControllerModel();
            model.Name = "LukLed";
            model.foo = "bar";
            model.Items.Add("AAA");
            model.Items.Add("BBB");
            model.Items.Add("CCC");
            return View(model);
        }
    
        [HttpPost]
        public ActionResult Index(HomeControllerModel model)
        {
            return View(model);
        }
    

    View:

    @using MvcApplication4.Controllers
    @model HomeControllerModel
    @{
        Layout = null;
    }
    <!DOCTYPE html>
    <html>
    <head>
        <title>Index</title>
    </head>
    <body>
        <div>
            <form action="/Home/Index" method="post">
            <div class="editor-label">
                @Html.LabelFor(model => model.Name)
            </div>
            <div class="editor-field">
                @Html.EditorFor(model => model.Name)
                @Html.ValidationMessageFor(model => model.Name)
            </div>
            <div class="editor-label">
                @Html.LabelFor(model => model.foo)
            </div>
            <div class="editor-field">
                @Html.EditorFor(model => model.foo)
                @Html.ValidationMessageFor(model => model.foo)
            </div>
            <div class="editor-field">
                @Html.EditorFor(model => model.Items)
            </div>
            <input type="submit" value="Submit" />
            </form>
        </div>
    </body>
    </html>
    

    You don’t have to iterate through Items.

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

Sidebar

Related Questions

I'm trying to make something that looks like: http://dev.sencha.com/deploy/ext-3.4.0/examples/grid/edit-grid.html But I want to change
So I'm using this plugin: jquery-in-place-editor , I'm trying to make a POST request
I'm trying to make something of a Tile-Map editor in C# using picture-boxes (the
So I've got this control I'm trying to make. It's an in-place text editor
Trying to make kinda WISYWIG editor that creates a div with some inner elements.
I am trying to make a html editor that allows you to preview the
I'm trying to make a patch 9 file for button so it looks like
I am trying to make a class to handle all my interactions with Facebook.
I'm trying to make a WYSIWYG editor, and so far I have it so
I'm trying to make a simple xml-editor for some basic but specific needs, the

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.