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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T22:25:29+00:00 2026-05-30T22:25:29+00:00

I am quite new to MVC but have been making steady progress however I

  • 0

I am quite new to MVC but have been making steady progress however I have recently hit a problem that I can’t seem to overcome despite reading a number of similar posts on similar topics.

I have a model as follows (simplified for brevity)

public virtual int Id { get; set; }

public virtual string Name { get; set; }

public virtual Address Address { get; set; }

I have a strongly typed view as follows:

@model JFS.Data.Model.Supplier

@using (Html.BeginForm())
{
    @Html.ValidationSummary(true)  

     <fieldset>
        <legend>Supplier Address</legend>

        <div class="editor-label">
            @Html.LabelFor(model => model.Address.AddressLine1)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Address.AddressLine1)
            @Html.ValidationMessageFor(model => model.Address.AddressLine1)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Address.Country)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Address.Country)
            @Html.ValidationMessageFor(model => model.Address.Country)
        </div>

    </fieldset>

And I have a shared EditorTemplate for the Country field as follows:

 @model JFS.Data.Model.Address

    @using System.Globalization

    @Html.DropDownListFor(o => o.Country, GetCountries(Model), "Please select")

    @functions
    {
        private static IEnumerable<SelectListItem> GetCountries(object country)
        {
            var regions = CultureInfo.GetCultures(CultureTypes.SpecificCultures)
                            .Select(cultureInfo => new RegionInfo(cultureInfo.LCID))
                            .OrderBy(r => r.EnglishName)
                            .Distinct()
                            .ToList();
            return new SelectList(regions, "TwoLetterISORegionName", "EnglishName", country);
        }
    }

I understand the problem but not sure how best to overcome it, any advice would be very much appreciated.

  • 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-30T22:25:31+00:00Added an answer on May 30, 2026 at 10:25 pm

    In your main view replace:

    @Html.EditorFor(model => model.Address.Country)
    

    with:

    @Html.EditorFor(model => model.Address)
    

    By the way if you are writing a shared editor template for an Address model you probably want to include the other properties as well such as AddressLine1 in this template.

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

Sidebar

Related Questions

I have to admit in advance that I'm quite new to MVC, I've been
I am quite new with Linq to SQL and MVC but I follow the
I am quite new with this MVC in ASP.NET. If I have a page
i have been working on a new .net MVC site and have integrated some
I'm quite new to MVC, and stumbled on a problem. I've googled a lot
I have recently started to examine ASP.NET MVC. I have studied quite a few
I have to start a new Spring MVC project and I've been reading about
I am quite new with MVC. I have a view with jQuery tabs (as
Despite I have been using MVC in PHP many times, I found out that
Im quite new to spring mvc. What I'm trying to achive is separating static

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.