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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T11:39:42+00:00 2026-05-30T11:39:42+00:00

So I have a big trouble handling the ICollection field on this model This

  • 0

So I have a big trouble handling the ICollection field on this model

This is my model

public class RegisterModel
{
    public RegisterModel() 
    {
        this.Servicios = new HashSet<Servicio>();
    }

    [Required(ErrorMessage="El nombre de usuario es requerido.")]
    [Display(Name = "Usuario")]
    public string UserName { get; set; }

    //[Required]
    [DataType(DataType.EmailAddress)]
    [Display(Name = "Email")]
    public string Email { get; set; }

    [Required(ErrorMessage = "La contraseña es obligatoria.")]
    [StringLength(100, ErrorMessage = "El {0} debe tener al menos {2} caracteres de longitud.", MinimumLength = 6)]
    [DataType(DataType.Password)]
    [Display(Name = "Contraseña")]
    public string Password { get; set; }

    [DataType(DataType.Password)]
    [Display(Name = "Confirmar contraseña.")]
    [Compare("Password", ErrorMessage = "La contraseña y la confirmacion no coinciden.")]
    public string ConfirmPassword { get; set; }

    [Required(ErrorMessage="Seleccione los servicios que desea agregar al usuario")]
    [Display(Name="Servicio")]
    public ICollection<Servicio> Servicios { get; set; } //This field
}

Now what I want to achieve it’s create a EditorTemplate for Servicio which actually I did it, but the problem it’s that in main view that’s strongly type for RegisterModel I don’t how to passed each Servicio from the ICollection<> to my EditorTemplate I tried like this but it doesn’t work

@model SodexoSAT.Models.RegisterModel

@using (Html.BeginForm()) {
@Html.ValidationSummary(true, "No se Pudo crear la cuenta. Por favor corrija los errores e inténtelo de nuevo.")
<div>
    <fieldset>
        <legend>Información de la cuenta</legend>

        <div class="editor-label">
            @Html.LabelFor(m => m.UserName)
        </div>
        <div class="editor-field">
            @Html.TextBoxFor(m => m.UserName)
            @Html.ValidationMessageFor(m => m.UserName)
        </div>

        <div class="editor-label">
            @Html.LabelFor(m => m.Password)
        </div>
        <div class="editor-field">
            @Html.PasswordFor(m => m.Password)
            @Html.ValidationMessageFor(m => m.Password)
        </div>

        <div class="editor-label">
            @Html.LabelFor(m => m.ConfirmPassword)
        </div>
        <div class="editor-field">
            @Html.PasswordFor(m => m.ConfirmPassword)
            @Html.ValidationMessageFor(m => m.ConfirmPassword)
        </div>

        <div class="editor-label">
            @Html.LabelFor(m => m.Servicios)
        </div>
        <div class="editor-field">
            <div>
                @Html.EditorFor(m => Model.Servicios) <--doesn't work
                @Html.EditorForModel(m => Model.Servicios) <--doesn't work
                @Html.EditorForModel(Model.Servicios) <--doesn't work too
            </div>
        </div>

        <p>
            <input type="submit" value="Crear Usuario" class="botonAtento" />
        </p>
    </fieldset>
</div>

}

  • 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-30T11:39:43+00:00Added an answer on May 30, 2026 at 11:39 am

    Replace

        <div class="editor-label">
            @Html.LabelFor(m => m.Servicios)
        </div>
        <div class="editor-field">
            <div>
                @Html.EditorFor(m => Model.Servicios) <--doesn't work
                @Html.EditorForModel(m => Model.Servicios) <--doesn't work
                @Html.EditorForModel(Model.Servicios) <--doesn't work too
            </div>
        </div>
    

    with

    @foreach(var service in m.Servicios)
    {
        <div class="editor-label">
            @Html.LabelFor(service)
        </div>
        <div class="editor-field">
            <div>
                @Html.EditorFor(service) <--doesn't work
            </div>
        </div>
    }
    

    That way, you’ll have the editor (with the attached label) per each service in Model.Services.

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

Sidebar

Related Questions

I have big trouble with file uploads with php. My own tests are successful
I have a big trouble with the multiplication of floats. here is the example:
I have this Caliburn.Micro sample project I'm putting together and I am having trouble
I have a big trouble with report services. I need to use a stored
I'm quite new to JavaScript and I have trouble working with etInterval() . I'm
So I have a big trouble understanding how to override a css rule inhered,
This is a big headache. I have a simple js file consisting of nothing
I am in big trouble at the moment. We have a huge JS library
I have big system that make my system crash hard. When I boot up,
I have big URL list, which I have to download in parallel and check

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.