title: Set a RadioButtonFor() checked by default within a Foreach loop
body: <p>I have a weird behavior using <code>@Html.RadioButtonFor</code> Extension Method. I am using a foreach loop to create a list of RadioButton and By ternary operator. I am trying to set the one who respect the condition to checked but It is always the last who is checked. I searched similars question but I am not sure to have found something. And I don't want to create/use a custom <code>RadioButtonList</code>.</p>
  
  <p>Here my code in my <strong>View</strong>:</p>
  
  <pre><code>@foreach (var item in Model.Entities)
          {
          &lt;div&gt;
                   @Html.RadioButtonFor(m =&gt; item.Default, item.EntityId,
                         new { @checked = item.Default ? "checked" : "" })//item.Default is a bool and there is only one set to True 
          &lt;/div&gt;
          }
  </code></pre>
  
  <p>But In my browser it is always the last created which is <code>checked</code> even if <code>item.Default</code> is <code>false</code>.
  So is there something</p>