title: Html.DropDownFor: Templates can be used only with field access, property access, single-dimension
body: <p>Updated:</p>
  
  <pre><code>@Html.DropDownListFor(m = item.SelectedType, (IEnumerable&lt;SelectListItem&gt;)ViewBag.DropDownLoadRecoveryType, new { @class = "form-control" 
  </code></pre>
  
  <p>Why am I getting this error:</p>
  
  <blockquote>
    <p>Templates can be used only with field access, property access,
    single-dimension array index, or single-parameter custom indexer
    express</p>
  </blockquote>
  
  <p>I have scan all the questions here before posting and I'm stuck and I need help please.</p>
  
  <p>here is my model:</p>
  
  <pre><code>public string SelectedType { get; set; }
  </code></pre>
  
  <p>here is my controller:</p>
  
  <pre><code>public static class RecoveryTypesDropDown
  {
      public static IEnumerable&lt;SelectListItem&gt; RecoveryTypes { get; set; }
  }
  
  public void DropDownLoadRecoveryType()
  {
     using (var context = new salt_entities())
     {
        var list = context.Types.OrderBy(b =&gt; b.Sort).ToList().Select(e =&gt; new { e.ID, e.Type });
        IEnumerable&lt;SelectListItem&gt; lists = list.Select(b =&gt; new SelectListItem { Value = b.ID.ToString().Trim(), Text = b.Type.Trim() }).ToList();
        RecoveryTypesDropDown.RecoveryTypes = lists;
      }
  }
  
  public ViewResult Collection(Guid id)
  {
     ViewBag.DropDownLoadRecoveryType = RecoveryTypesDropDown.RecoveryTypes;
     //....
     foreach (var item in collectionViewModelList)
     {
       //....
  
       collectionViewModel.SelectedType = item.Type.Value;
  
     }
  
  }
  </code></pre>
  
  <p>here is my .html razor code:</p>
  
  <pre><code>  @model IEnumerable&lt;myapp.Models.CollectionViewModel&gt;
  
    @foreach (var item in Model)
    {
       @Html.DropDownList(item.SelectedType.Trim(), (IEnumerable&lt;SelectListItem&gt;)ViewBag.DropDownLoadRecoveryType, new { @class = "form-control" })
    }
  </code></pre>