title: Multiple radio button groups in MVC 4 Razor
body: <p>I need to have multiple radio button groups in my form like this:<br>
  <img src="https://i.stack.imgur.com/Bnk06.jpg" alt="enter image description here">  </p>
  
  <p>I know it's simply done by specifying the same "<em>name</em>" html attribute for each group.<br>
  <strong>HOWEVER</strong><br>
  MVC doesn't let you specify your own name attribute when using html helper like this:</p>
  
  <pre><code>@Html.RadioButtonFor(i =&gt; item.id, item.SelectedID, new { Name = item.OptServiceCatId })  
  </code></pre>
  
  <p><strong>Because</strong> it looks at each tag's "<em>name</em>" attribute (not "<em>id</em>") to map/bind the form to the model which the controller receives, etc.  </p>
  
  <p>Some said that specifying each with the same "GroupName" attribute will solve the problem, but it didn't work either.</p>
  
  <p>So, is there any way which works ?</p>
  
  <p><strong>EDIT:</strong><br>
  Here's my view (simplified):</p>
  
  <pre><code>@model Service_Provider.ViewModels.SelectOptServicesForSubServiceViewModel
  
  @foreach (var cat in Model.OptServices)
  {
    //A piece of code &amp; html here
    @foreach (var item in cat.OptItems.Where(i =&gt; i.MultiSelect == false))
    {
       @Html.RadioButtonFor(i =&gt; item.id, item.SelectedID, new { GroupName = item.OptServiceCatId })
  &lt;br /&gt;
    }    
  }
  </code></pre>
  
  <p><strong>NOTE:</strong><br>
  My model is a <code>List&lt;OptServices&gt;</code>:</p>
  
  <pre><code>public List&lt;OptServices&gt; Cats {get; set;}
  </code></pre>
  
  <p>And OptServices has a <code>List</code> of <code>OptItems</code> inside:</p>
  
  <pre><code>public class OptServices
  {
  //a few things
  public List&lt;OptItems&gt; Items {get; set;}
  }
  </code></pre>