Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>By default when you use <code>Html.EditorForModel</code> don't expect this to recurse down to complex properties such as your <code>Tipos</code> property which is of type <code>IEnumerable&lt;SelectListItem&gt;</code>. Brad Wilson explained this in his <a href="http://bradwilson.typepad.com/blog/2009/10/aspnet-mvc-2-templates-part-4-custom-object-templates.html" rel="nofollow">blog post</a> (more specifically read the <strong>Shallow Dive vs. Deep Dive</strong> section towards the end of the post). You will need to write a custom editor template for the Object type if you want this to happen.</p> <p>Another possibility is to specify the template name:</p> <pre><code>@Html.EditorFor(x =&gt; x.Tipos, "SelectListItem") </code></pre> <p>Also bear in mind that your editor template for the <code>SelectListItem</code> is wrong because you are binding the DropDownListFor to the model as first argument. Don't forget that the first argument of this helper must be a scalar property that will be used to hold the selected value. You need a string or integer property on your view model for this. The second argument represents the collection.</p> <p>Another important aspect about editor templates is that when you have a property of type <code>IEnumerable&lt;T&gt;</code> and an editor template called <code>T.cshtml</code> this editor template must be strongly typed to the <code>T</code> class and not <code>IEnumerable&lt;T&gt;</code> as you did with your <code>SelectListItem.cshtml</code> template. This doesn't apply if you use UIHint or specify the template name as second argument to the EditorFor helper. n this case the template will be typed to the collection.</p> <p>So to recap, you could either implement a custom object editor template as Brad Wilson suggested that will recurse down to complex properties or you could modify your <code>_Formulario.cshtml</code> view to specify EditorFor each individual elements.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload