title: converting int to string for dropdownlistfor
body: <p>I have an int property for Age, and a selectlist of possible ages to choose from.  When retrieving the data for editing, I am getting an error when adding the tostring() method that says: </p>
  
  <blockquote>
    <p>Templates can be used only with field access, property access, single-dimension array index, or single-parameter custom indexer expressions.</p>
  </blockquote>
  
  <p>so my viewmodel looks like:</p>
  
  <pre><code>public int LowerAgeLimit { get; set; }
  public List&lt;SelectListItem&gt; Ages { get; set; }
  </code></pre>
  
  <p>My query is retrieving the data correctly, and then in the view I am trying to have data displayed like this:</p>
  
  <pre><code>@Html.DropDownListFor(x =&gt; x.LowerAgeLimit.ToString()
                        , Model.CreateGroupForm.Ages
                        , new { @class = "form-control" })
  </code></pre>
  
  <p>Without the tostring() method, it displays blank which makes sense as it is expecting a string. But it won't let me convert to a string without the error.  I've also tried creating a new string Age property in the viewmodel, and converting the int to a string in the query, but I still can't get the dropdownlist to display the value.</p>
  
  <p>In the query I have populated the ages list as follows:</p>
  
  <pre><code>model.CreateGroupForm.Ages.Insert(0, (new SelectListItem { Text = "", Value = "" }));
          for (int i = 1; i &lt; 100; i++)
          {
  
              model.CreateGroupForm.Ages.Insert(i, (new SelectListItem {Text = i.ToString(), Value = i.ToString()}));
          }
  </code></pre>