title: Group radio buttons in foreach loop in MVC razor view?
body: <p>I have tried to group a set of radio buttons inside loop by providing additional html attribute in html help as below -</p>
  
  <pre><code>&lt;ol class="Opt"&gt;
      @foreach (var opt in quest.Options)
      {
          &lt;li class="Opt"&gt;
              @Html.RadioButtonFor(o =&gt; opt.Title, opt.Title, new { @name = "uniqueRadio"})
              @Html.Label(opt.Title)
          &lt;/li&gt;
      }
  &lt;/ol&gt;
  </code></pre>
  
  <p>However name attribute ot generated input html tag gets over-written by <strong>opt.Title</strong> for obvious reasons. MVC-4 uses name attribute for strongly typed model-binding when posting data.</p>
  
  <p>How do I make radio button grouped together ?</p>
  
  <p>EDIT: I replaced RadioButtonFor with RadioButton, as suggested below. But this way I miss-out model binding feature.</p>
  
  <pre><code>&lt;ol class="Question"&gt;
      @for (int j = 0; j &lt; Model.Options.Count; j++)
      {
          &lt;li class="Opt"&gt;                    
              @Html.RadioButton("uniqueRadio", Model.Options[j].IsSelected, false)
              @Model.Options[j].Title
          &lt;/li&gt;
      }
  &lt;/ol&gt;
  </code></pre>