title: How can I bind a radio button with model data in ASP.Net MVC?
body: <p>I want to show a radio button in my form which will be populated from model data.</p>
  
  <h2>here is my model</h2>
  
  <pre><code>public class Student
      {
          [Required(ErrorMessage = "First Name Required")] // textboxes will show
          [Display(Name = "First Name :")]
          [StringLength(5, ErrorMessage = "First Name cannot be longer than 5 characters.")]
          public string FirstName { get; set; }
  
  [Required(ErrorMessage = "Last Name Required")] // textboxes will show
          [Display(Name = "Last Name :")]
          [StringLength(5, ErrorMessage = "Last Name cannot be longer than 5 characters.")]
          public string LastName { get; set; }
  
  [Required(ErrorMessage = "Sex Required")] // group of radio button will show
          [Display(Name = "Sex :")]
          public List&lt;Sex&gt; Sex { get; set; }
  
  }
  
  public class Sex
      {
          public string ID { get; set; }
          public string Type { get; set; }
      }
  </code></pre>
  
  <p>here I am trying to populate the student model manually from an action method like</p>
  
  <pre><code>public ActionResult Index()
  {
  var student=  new Student 
  {
      FirstName = "Rion",
      LastName = "Gomes",
  
      Sex= new List&lt;Sex&gt;
          {
              new Sex{ID="1" , Type = "Male"}, 
              new Sex{ID="2" , Type = "Female"}
          }    
  }    
      return View(student);
  }
  </code></pre>
  
  <p>now how could I generate a radio button which will <code>display text in form Male &amp; Female</code> and as value will have the <code>ID</code></p>
  
  <p>I searched google and found many samples and I used one but not sure if it works.
  here is the radio button code in view.</p>
  
  <pre><code>@Html.RadioButtonFor(x =&gt; x.Sex, "Male")
  </code></pre>
  
  <p>I do not want to hard code male or female rather; I want to show it through a model and want to generate the radio button in a for loop.</p>
  
  <p>I am new too MVC, so please guide me.</p>