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

  • Home
  • SEARCH
  • 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 7439483
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:42:47+00:00 2026-05-29T10:42:47+00:00

Someone please help me return this list properly from my view. I don’t see

  • 0

Someone please help me return this list properly from my view. I don’t see why I’m returning null for my fieldModelList I try to pass to the controller…

Here is my view:

@model List<Regions.SOA.UI.CopyBookSchemaCreator.Models.FieldModel>

<script type="text/javascript" src="~/Scripts/jquery-ui-1.8.11.min.js"></script>

@using (Html.BeginForm("GetResponse", "TestMethods", FormMethod.Post))
{

<table id="tblMethods">
    <tr>
        <th>
            Property Name
        </th>
        <th>
            Request
        </th>
    </tr>

    @foreach (FieldModel fieldModel in Model) 
    {
        <tr>
            <td>
                @Html.DisplayFor(m => fieldModel.PropertyName)
            </td>
            <td>
                @Html.TextBoxFor(m => fieldModel.PropertyValue)
            </td>
        </tr>
    }

</table>

<div>
    <input type="submit"/>       
</div>

and here is my controller:

    [HttpPost]
    public ActionResult GetResponse(List<FieldModel> fieldModelList)
    {
        return GetResponse(fieldModelList);   
    }

I am hitting the HttpPost method but if I place a breakpoint just inside it, I am returning null for the fieldModelList right off the bat, which I was hoping would be a list of the values I entered into the texboxes on the view that is of model FieldModel…

I think something is wrong with my logic versus my syntax, or as maybe as well as my syntax, but basically what I want to do is return back a list of type FieldModel with each corresponding PropertyName and PropertyValue to the controller. I noticed I am not passing any kind of id parameter in my BeginForm statement in the view. Do I need one here?

Just in case, here is my model class for FieldModel:

namespace Regions.SOA.UI.CopyBookSchemaCreator.Models
{
    public class FieldModel
    {
        [Display(Name = "Property")]
        public string PropertyName { get; set; }

    [Display(Name = "Value")]
        public string PropertyValue { get; set; }
    }
}
  • 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-29T10:42:47+00:00Added an answer on May 29, 2026 at 10:42 am

    Phil Haack wrote an article some time ago explaining how to bind collections (ICollection) to view models. It goes into additional detail about creating an editor template, which you could certainly do as well.

    Basically, you need to prefix the HTML elements’ name attributes with an index.

    <input type="text" name="[0].PropertyName" value="Curious George" />
    <input type="text" name="[0].PropertyValue" value="H.A. Rey" />
    
    <input type="text" name="[1].PropertyName" value="Ender's Game" />
    <input type="text" name="[1].PropertyValue" value="Orson Scott Card" />
    

    Then, your controller could bind the collection of FieldModel

    [HttpPost]
    public ActionResult GetResponse(List<FieldModel> fieldModelList)
    {
        return GetResponse(fieldModelList);   
    }
    

    I’m not 100% sure the following would name the attributes correctly (I’d recommend using the editor template) but you could easily use the htmlAttributes argument and give it a name using the index.

    @for(int i = 0;i < Model.Count;i++) 
    {
        <tr>
            <td>
                @Html.DisplayFor(m => m[i].PropertyName)
            </td>
            <td>
                @Html.TextBoxFor(m => m[i].PropertyValue)
            </td>
        </tr>
    }
    

    Editor Template

    If you wanted to go as far as adding an editor template, add a partial view named FieldModel.ascx to /Views/Shared that is strongly typed to a FieldModel

    @model Regions.SOA.UI.CopyBookSchemaCreator.Models.FieldModel
    
    @Html.TextBoxFor(m => m.PropertyName) @* This might be a label? *@
    @Html.TextBoxFor(m => m.PropertyValue)
    

    And, then the part of your view responsible for rendering the collection would look like:

    @for (int i = 0; i < Model.Count; i++) { 
        @Html.EditorFor(m => m[i]);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

can someone please help me. why does this return an error: Dim stuff As
Could someone please help explain why I can't get this to work? I properly
Can someone please help me out with a JavaScript/jQuery solution for this arithmetic problem:
Can someone please help me figure out a way to achieve the following (see
Can someone please help me understand why this isn't working? The loading.gif appears while
Will someone please help me with this jQuery bit.ly URL shortener? The code is
Can someone please help me understand how I would write this. If i am
Can someone please help me with this conditional field validation in CodeIgniter? Trying to
I am fighting this thing and cannot figure it out... can someone please help.
Someone please help. I have an interesting issue. I am trying to implement an

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.