title: How to use dynamically Radiobutton in ASP.NET MVC
body: <p>I am creating a Poll in my ASP.NET MVC project.</p>
  
  <p>1) I select poll and it's replies as an object of <code>Poll</code> model from database [poll model contain a list of reply model that named <code>PollReplies</code>]:</p>
  
  <p>Poll model:</p>
  
  <pre><code>public class Poll
  {
      public Poll() {
          PollReplies = new List&lt;PollReply&gt;();
      }
      public int ID { get; set; }
      public System.DateTime CDate { get; set; }
      public System.DateTime SDate { get; set; }
      public System.DateTime EDate { get; set; }
      public string User_ID { get; set; }
      public string Title { get; set; }
      public int Language_ID { get; set; }
      public bool IsActive { get; set; }
      public bool IsPublic { get; set; }
      public bool ResultIsPublic { get; set; }
      public List&lt;PollReply&gt; PollReplies { get; set; }
  }
  </code></pre>
  
  <p>Reply model:</p>
  
  <pre><code>public class PollReply
  {
      public int ID { get; set; }
      public int Poll_ID { get; set; }
      public string Title { get; set; }
      public int Count { get; set; }
      public bool IsChecked { get; set; }
  }
  </code></pre>
  
  <p>2) I render poll title of the selected poll object as question of poll.</p>
  
  <p>3) With a <code>for</code> render replies:</p>
  
  <pre><code>for (int i = 0; i &lt; Model.PollReplies.Count; i++)
  {
      @Html.HiddenFor(model =&gt; model.PollReplies[i].ID, new { @Value = Model.PollReplies[i].ID })
      counter++;
      &lt;tr&gt;
          &lt;td&gt;@counter&lt;/td&gt;
          &lt;td&gt;@Html.DisplayFor(model=&gt;model.PollReplies[i].Title)&lt;/td&gt;
          &lt;td&gt;
              @Html.RadioButtonFor(model =&gt; model.PollReplies[i].IsChecked,counter)
          &lt;/td&gt;
      &lt;/tr&gt;
  }
  </code></pre>
  
  <p>My problem:</p>
  
  <p>1) When I submit form, The <code>Poll</code> model is contain all replies. All replies has <code>ID</code> but the <code>IsChecked</code> propery of replies not set with the client selected radiobutton!(all <code>IsChecked</code> of replies are false) How I can post the selected reply as true?</p>
  
  <p>2) I am using <code>@Html.RadioButtonFor</code> and radios give name attributes automaticly, so the name attribute of generated inputs are diffrente, but i need to just select one of radios! What is the best solution?</p>