title: In a custom editor template, how do I access the field name I should use for the edit control?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/6615541/how-to-get-models-field-name-in-custom-editor-template">How to get model&#39;s field name in custom editor template</a>  </p>
  </blockquote>
  
  
  
  <p>When outputting an edit control for a special type of entity, for example, let’s say a color or something:</p>
  
  <pre><code>@Html.EditorFor(product =&gt; product.Color)
  </code></pre>
  
  <p>I want this to output a drop-down list, so I tried to create a custom editor template that shall render such a drop-down. Here is what my template looks like so far:</p>
  
  <pre><code>@model MyProject.Models.Color
  @using (var db = new MyProject.Models.DbContext())
  {
      @Html.DropDownList(???,
          new SelectList(db.Colors, "Id", "Name", Model))
  }
  </code></pre>
  
  <p>What do I have to put instead of the <code>???</code> — the parameter that specifies the HTML <code>name</code> attribute for the drop-down?</p>
  
  <hr>
  
  <p>(For obvious reasons, it’s not just <code>"Color"</code>. Consider several invocations of the same edit template for <em>different</em> fields of the <em>same</em> type, e.g.:</p>
  
  <pre><code>@Html.EditorFor(product =&gt; product.InnerColor)
  @Html.EditorFor(product =&gt; product.OuterColor)
  </code></pre>
  
  <p>Clearly, this needs to generate drop-downs with different names.)</p>