Hamza Jutt

Hamza Jutt

  • NA
  • 13
  • 689

Generate Matrix layout quiz question

Dec 24 2021 8:58 PM

I have two tables in one table i have question id and question name and other table have option id , option namee and question id i have to view question and his option on screen and this is my code but problem is question is writen with every option and i want 1 question and his options can anyone help me on this

public class ExamController : Controller
{
    Exam_systemEntities1 dbobj = new Exam_systemEntities1();
    public ActionResult Question_Paper(int id)
    {
        return View(dbobj.Sp_Question_Paper(id).ToList());
    }
}


@model IEnumerable<ExamSystem.Models.Sp_Question_Paper_Result>
@{
    ViewBag.Title = "Detail_View_Question";
    char i = 'a';
}
<h2>Detail_View_Question</h2>
@using (Html.BeginForm())
{
    <center></center>
    foreach (var item in Model)
    {
        <h3>@item.question_name</h3>
        foreach(var itemm in Model)
        {
        <p> @i) @item.option_name<br> </p>
        }
        i++;
    }
}