title: "Templates can be used only with field access, property access, single-dimension array index, or single-parameter custom indexer expressions" error
body: <p>Why am I receiving the error:</p>
  
  <blockquote>
    <p><em>Templates can be used only with field access, property access, single-dimension array index, or single-parameter custom indexer expressions</em></p>
  </blockquote>
  
  <p>at this code:</p>
  
  <pre><code>@model IEnumerable&lt;ArtSchoolProject.Models.Trainer&gt;
  
  @{
  ViewBag.Title = "Index";
  Layout = "~/Views/Shared/_PageLayout.cshtml";
  }
  
  &lt;h2&gt;Index&lt;/h2&gt;
  
  &lt;p&gt;
  @Html.ActionLink("Create New", "Create")
  &lt;/p&gt;
  &lt;ul class="trainers"&gt;
  
  
  @foreach (var item in Model) {
  &lt;li&gt;
    &lt;div&gt;
        &lt;div class="left"&gt;
            &lt;a href="@Url.Action("Details", "Details", new { id = item.ID })"&gt;
                &lt;img src="~/Images/Trainer/@item.Picture" /&gt;
            &lt;/a&gt;
        &lt;/div&gt;
        &lt;div class="right"&gt;
            @Html.ActionLink(item.Name,"Details",new {id=item.ID})
            &lt;br /&gt;
            @Html.DisplayFor(modelItem=&gt;@string. item.Description.ToString().Substring(0,100))
        &lt;/div&gt;
    &lt;/div&gt;
    &lt;/li&gt;
    }
  
    &lt;/ul&gt;
  </code></pre>
  
  <p>at line:</p>
  
  <pre><code>@Html.DisplayFor(modelItem=&gt;item.Description.ToString().Substring(0,100))
  </code></pre>
  
  <p>Update:</p>
  
  <p>Problem solved. I added to my code :</p>
  
  <pre><code>  @{
  string parameterValue = item.Description.ToString().Substring(0, 100); 
            }
            @Html.DisplayFor(modelItem=&gt;parameterValue)
  </code></pre>
  
  <p>My new code:</p>
  
  <pre><code>@foreach (var item in Model) {
  &lt;li&gt;
    &lt;div&gt;
        &lt;div class="left"&gt;
            &lt;a href="@Url.Action("Details", "Details", new { id = item.ID })"&gt;
                &lt;img src="~/Images/Trainer/@item.Picture" /&gt;
            &lt;/a&gt;
        &lt;/div&gt;
        &lt;div class="right"&gt;
            @Html.ActionLink(item.Name,"Details",new {id=item.ID})
            &lt;br /&gt;
            @{
  string parameterValue = item.Description.ToString().Substring(0, 100); 
            }
            @Html.DisplayFor(modelItem=&gt;parameterValue)
        &lt;/div&gt;
    &lt;/div&gt;
   &lt;/li&gt;
  }
  </code></pre>
  
  <p>This is only one possibility. Just for curiosity is there another solution for solving the error?</p>