title: Unique Id for each element in a foreach loop in an asp.net mvc 3 view?
body: <p>I have a collection of ViewModels that I send back to from controller to the view</p>
  
  <pre><code>   public class CourseTableViewModel
      {
          public string Prefix { get; set; }
          public bool OwnerPremission { get; set; }
          public bool AddPermission { get; set; }
          public bool EditPermission { get; set; }
          public bool DeletePermission { get; set; }
          public bool ViewPermission { get; set; }
      }
  </code></pre>
  
  <p>So I have a list of these</p>
  
  <pre><code>@foreach (var item in Model)
          {     
              &lt;tr&gt;
                 &lt;td&gt;@Html.CheckBoxFor(x =&gt; item.OwnerPermission) &lt;/td&gt;
                 //.... rest here //
              &lt;/tr&gt;
  
          }
  </code></pre>
  
  <p>This will loop around X amount of times depending on how VM's is being sent back but they all with have the same id and I want them different.</p>
  
  <p>So I did this</p>
  
  <pre><code>&lt;td&gt;@Html.CheckBoxFor(x =&gt; item.OwnerPremission,new {@disabled = "disabled", @id = PermissionTypes.Owner.ToString() + counter})&lt;/td&gt;
  </code></pre>
  
  <p>I am wondering if there is a better way.</p>
  
  <p><strong>Edit</strong></p>
  
  <p>So I did the template way(display not edit though) and have in it this</p>
  
  <pre><code>  &lt;td&gt;@Html.CheckBoxFor(x =&gt; x.OwnerPremission, new { @disabled = "disabled"})&lt;/td&gt;
  </code></pre>
  
  <p>It renders this for the first one.</p>
  
  <pre><code>&lt;td&gt;&lt;input type="checkbox" value="true" name="[0].OwnerPremission" disabled="disabled" checked="checked"&gt;&lt;input type="hidden" value="false" name="[0].OwnerPremission"&gt;&lt;/td&gt;
  </code></pre>
  
  <p>There is no id just name. Why does it not show up?</p>