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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:54:50+00:00 2026-06-17T16:54:50+00:00

This is my editor template for displaying a fixed list of provinces with a

  • 0

This is my editor template for displaying a fixed list of provinces with a checkbox for each province:

@model Comair.RI.UI.Models.ApplicantRelocateProvinceList
<table>
    <tr>
        <th style="display: none;"></th>
        <th>
            @Html.DisplayNameFor(model => model.HeaderItem.Province)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.HeaderItem.WillRelocate)
        </th>
    </tr>
    @foreach (var item in Model.Items)
    {
        @Html.EditorFor(m => item)
    }
</table>

This is the editor template for the Model.Items type model:

@model Comair.RI.UI.Models.ApplicantRelocateProvinceItem
<tr>
    <td style="display: none;">
        @Html.HiddenFor(m => m.Id)
    </td>
    <td>
        @Html.DisplayFor(m => m.Province.Name)
    </td>
    <td>
        @Html.EditorFor(m => m.WillRelocate)
    </td>
</tr>

I have used this model successfully for other view models. Here is the ApplicantRelocateProvinceList model:

public class ApplicantRelocateProvinceList : ViewModel
{        
    public ApplicantRelocateProvinceItem HeaderItem { get; set; }
    public ApplicantRelocateProvinceList()
    {
        HeaderItem = new ApplicantRelocateProvinceItem();
    }
    public void MapFromEntityList(IEnumerable<ApplicantRelocateProvince> applicantProvinces)
    {
        var service = new ProvinceService(DbContext);
        var selectedIds = applicantProvinces.Select(ap => ap.ProvinceId);
        Items = service.ReadProvinces()
                       .Where(i => !i.IsDeleted)
                       .Select(p => new ApplicantRelocateProvinceItem {Id = p.Id, Province = p, WillRelocate = selectedIds.Contains(p.Id)});
    }
    public IEnumerable<ApplicantRelocateProvinceItem> Items { get; set; }
}

This code reads a fixed list of our nine provinces, and a variable list of provinces chosen by the applicant. Those of the fixed provinces whose IDs are in the applicant’s provinces are marked with their WillRelocate flag as true, to show its checkbox as checked.

  • 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-06-17T16:54:50+00:00Added an answer on June 17, 2026 at 4:54 pm

    I think problem could be in this line:

    @Html.EditorFor(m => item)
    

    Try this:

    @Html.EditorForModel(item)
    

    Similar question: Why not use Html.EditorForModel()

    Added:

    Special folder must be named EditorTemplates, parent folder must be named as controller (for example Home) or Shared (for all controllers) and view name must be ApplicantRelocateProvinceItem.cshtml as class name.

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

Sidebar

Related Questions

I've got an editor template which renders out a checkbox: @Html.CheckBoxFor(model => model.Follow) Which
I have created this editor template: @model DateTime? @using MyMvcApp.Properties <div id=dateTimePicker_@(ViewData.ModelMetadata.PropertyName)> <script type=text/javascript
I am using an editor template to display a checkbox for each role a
I originally created an editor template like this @model MyModel var items = //
Similar to this post IEnumerable model property in an ASP.NET MVC 3 Editor Template
I'm trying to display a view model using an editor template that wraps the
I'm using an Editor Template, the syntax in the view looks like this: Html.EditorFor(m
I've got a custom Editor Template that is essentially: <div id=control> <%: Html.DropDownListFor(model =>
I hava an editor template for, let's say, date: @model DateTime @section AdditionalJavaScript2 {
I have the following editor template @model DateTime? @Html.TextBox(, (Model.HasValue ? Model.Value.ToShortDateString() : string.Empty),

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.