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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:04:54+00:00 2026-05-26T03:04:54+00:00

This is how I populate the view from the viewmodel PersonInformation.. @model Client.Models.PersonInformation <fieldset>

  • 0

This is how I populate the view from the viewmodel PersonInformation..

@model Client.Models.PersonInformation

<fieldset>
    <legend>Contact Information</legend>

    @foreach (var item in Model.MemberContacts) 
    {
        <div class="editor-label">
            @Html.DisplayFor(model => item.MemberContactDescription)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => item.ContactInformation)
            @Html.ValidationMessageFor(modelitem => item.MemberContactDescription)
        </div>
    }
</fieldset>

And the ViewModel

public class PersonInformation
{
    public Person person { get; set; }
    public Address premiseAddress { get; set; }
    public Address billingAddress { get; set; }

    private ICollection<MemberContact> _MemberContacts { get; set; }
    public virtual ICollection<MemberContact> MemberContacts
    {
        get { return _MemberContacts ?? (_MemberContacts = new HashSet<MemberContact>()); }
        set { _MemberContacts = value; }
    }

    public  PersonInformation()
    {
        BIMemberService lib = new BIMemberService();
        ICollection<MemberContact> mcs = new List<MemberContact>();

        foreach (ContactLib itm in lib.ContactLibs())
        {
            MemberContact mc = new MemberContact();
            mc.MemberContactDescription = itm.Description;
            mc.ContactLibID = itm.ContactLibId;
            mc.ContactInformation = "test";
            mcs.Add(mc);
            MemberContacts.Add(mc);
        }
    }
}

But this one (which has an input text field), do not have a value on the post action.

@Html.EditorFor(model => item.ContactInformation)

This is my post action.

[HttpPost]
    public ActionResult PersonInformation(PersonInformation member)
    {
        if (ModelState.IsValid)
        {
            db.Apply(member);
            return View("Requirements", member.person.MemberRequirements);
        }
        return View(member);
    }

Tracing down the code, the line below produces null value

member.MemberContacts.ContactInformation

Any advise, is highly appreciated.

Thanks

  • 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-26T03:04:55+00:00Added an answer on May 26, 2026 at 3:04 am

    You are trying to use editor for with an arbitrary item of a collection.

    try reading this post. It should give you some insight on collection binding

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

Sidebar

Related Questions

Suppose I have this model: public class ViewModel { [Required] public string UserInput {
There are several examples of how to populate a tree view from a collection
This is the ViewModel: using System; using System.Collections.Generic; using System.Linq; using System.Web; using AfvClassifieds.Models;
I have an ASP.Net MVC view which inherits from a ViewModel. The ViewModel contains
I use a foreach in my View to loop over my strongly-typed Model and
I have a View Model that has some serious nesting. I need to populate
Application : HTA (therefore IE) This is an application that uses SendKeys to populate
I basically want to do this in code: PersonList myPersonList; //populate myPersonList here, not
There's this already populated database which came from another dev. I'm not sure what
I have an app with a Master-Details view. When you select an item from

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.