TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Jagan Mohan
NA
7
810
set specific items per page in MVC4
Dec 8 2015 9:51 AM
I have mutiple questions and answer in the list. i need to display in view like (suppose i have 30 questions and answers) from that list i'm goign to display first 5 questions and answers with next button and again if i click on next button next 5 questions and answers and so on until 30 questions over and finish the test(means submit the questions and answers).
In Controller
public ActionResult Solution()
{
List<QuestionsModel> items;
decimal testid = 1;
decimal skillId = 1;
items = (from p in db.ALBulkTestDetails
where ( p.TestID == testid && p.SkillID == skillId)
select new QuestionsModel
{
ID = p.QuestionID,
SkillId = p.SkillID,
QuestionText = p.Question,
Options = (from a in db.ALBulkTestDetails
join b in db.ALBulkTestDetails
on new { aa = a.QuestionID, a.SkillID } equals new { aa = b.QuestionID, b.SkillID }
where b.QuestionID == p.QuestionID && b.SkillID == p.SkillID
select new Answer
{
AnswerId = b.AnswerId,
Option1 = b.Option1,
Option2 = b.Option2,
Option3 = b.Option3,
Option4 = b.Option4
}).ToList()
}).ToList();
Session["itemsTimerCount"] = items.Count();
return View(items);
}
In View :
@model List<TestQuestions.Models.QuestionsModel>
@{
ViewBag.Title = "Solution";
Layout = "~/Views/Shared/_Layout.cshtml";
}
@using (Html.BeginForm("Solution", "Home", FormMethod.Get, new { enctype = "multipart/form-data" }))
{
<div class="panel panel-default">
<div class="panel-heading panel-heading-custom" style=" background-color: #d34646;color: #fff;font-size: 20px;" ;>
<i class="fa fa-bar-chart-o fa-fw"></i> ASP.NET TEST
</div>
<div class="panel-body">
<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
<div class="panel panel-default" id="ques1">
<input type="hidden" value="@Session["itemsTimerCount"]" id="hdnFlag" />
@{int i = 0;}
@for (int j = 0; j < Model.Count; j++)
{
i++;
<div class="panel-heading online-test" role="tab" id="">
<h5 class="panel-title">
@Html.HiddenFor(m => m[j].ID)
@Html.HiddenFor(m => m[j].SkillId)
@i) @Html.DisplayFor(m => m[j].QuestionText)
</h5>
</div>
foreach (var k in Model[j].Options)
{
<div class="panel-collapse">
<div class="panel-body online-test-options">
<div class="input-group">
<div class="col-lg-12" id="radiolist">
@Html.RadioButtonFor(m => m[j].SelectedAnswer, "1")
<label for="@k.AnswerId">@k.Option1</label>
</div>
<div class="col-lg-12">
@Html.RadioButtonFor(m => m[j].SelectedAnswer, "2")
<label for="@k.AnswerId">@k.Option2</label>
</div>
<div class="col-lg-12">
@Html.RadioButtonFor(m => m[j].SelectedAnswer, "3")
<label for="@k.AnswerId">@k.Option3</label>
</div>
<div class="col-lg-12">
@Html.RadioButtonFor(m => m[j].SelectedAnswer, "4")
<label for="@k.AnswerId">@k.Option4</label>
</div>
</div>
</div>
</div>
}
<br />
}
</div>
</div>
<div>
<input type="submit" value="Next" class="btn btn-info btn-lg" />
</div>
</div>
</div>
}
Please help me how to do ?
Thanks in Advance
Reply
Answers (
2
)
WhatsUp API Integration
read csv in dataset with String dataType of all columns