title: Passing selected value from the radio buttons to the controller in MVC
body: <p>I'm trying to pass this selected radio button value from the razor view to the controller.... 
  can someone please give me an idea how to do this?.....................
  My View looks like this:</p>
  
  <pre><code>@using (Html.BeginForm("Index", "Exam"))
  {
  
      @Html.Hidden("qid", Model.ID, new { @id = "id" })
      &lt;table&gt;
          &lt;tr&gt;
              &lt;td&gt;
                  @Model.ID
              &lt;/td&gt;
              &lt;td&gt;
                  @Model.QuestionDes
              &lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;
                  &lt;p&gt;@Html.RadioButton("Answer1", new { @id = 1 })  @Model.Answer1 &lt;/p&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;
                  &lt;p&gt;@Html.RadioButton("Answer2", new { @id = 2 })  @Model.Answer2 &lt;/p&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;
                  &lt;p&gt;@Html.RadioButton("Answer3", new { @id = 3 })  @Model.Answer3 &lt;/p&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;
                  &lt;p&gt;@Html.RadioButton("Answer4", new { @id = 4 })  @Model.Answer4 &lt;/p&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
  
      &lt;/table&gt;
  
      &lt;input type="submit" value="Next" /&gt;
  
  }
  @using (Html.BeginForm("PrevIndex", "Exam"))
  {
  
      @Html.Hidden("qid1", Model.ID, new { @id = "id1" })
      &lt;input value="Prev" type="submit" /&gt;
  }
  </code></pre>
  
  <p>My Controller looks like this:.........</p>
  
  <pre><code> public class ExamController : Controller
      {
          [HttpGet]
          public ActionResult Index()
          {
              IQuestionService ser = new QuestionService();
              QuestionLoadDTO q = ser.GetIndividualQuestions(1);
              return View(q);
          }
  
          [HttpPost]
          public ActionResult Index(QuestionLoadDTO ques)
          {
              int count = 0;
              count = int.Parse(Request["qid"].ToString());
              count++;
              if (count &lt;= 4)
              {
                  IQuestionService ser = new QuestionService();
                  QuestionLoadDTO q = ser.GetIndividualQuestions(count);
                  return View(q);
              }
              return RedirectToAction("Submit");
  
          }
          public ActionResult PrevIndex(QuestionLoadDTO ques)
          {
              int count1 = 0;
              count1 = int.Parse(Request["qid1"].ToString());
              count1--;
              if (count1 &lt; 5 || count1 &gt;= 0)
              {
                  IQuestionService ser = new QuestionService();
                  QuestionLoadDTO q = ser.GetIndividualQuestions(count1);
                  return View("Index", q);
              }
              return RedirectToAction("End");
  
          }
          public ActionResult Submit()
          {
              return View();
          }
          public ActionResult End()
          {
              return View();
          }
  
  
  
  
      }
  </code></pre>
  
  <p>These are the other methods:</p>
  
  <pre><code>QuestionLoadDTO IQuestionService.GetIndividualQuestions(int index)
  {
      IQuestionData ser = new QuestionRepository();           
  
      QuestionLoadDTO q = ser.GetIndividualQues(index);
  
      return q;
  }
  public QuestionLoadDTO GetIndividualQues(int index)
  {
      Context con = new Context();
      Question question = con.Questions.Find(index);//Where(e =&gt; e.ID == index).FirstOrDefault();
      QuestionLoadDTO dto = new QuestionLoadDTO()
      {
          ID = question.ID,
          QuestionDes = question.QuestionDes,
          Answer1 = question.Answer1,
          Answer2 = question.Answer2,
          Answer3 = question.Answer3,
          Answer4 = question.Answer4
  
      };                                
      return dto;
  }
  </code></pre>
  
  <p>Thank you!!!!</p>