0

I'm working on an exam system . I created a List view to display all the Multiple choice or True false Questions then I need to set the paging to 5 Questions per page.

The issue here is the total of the multiple choices Answers for each question changing {1choice,2choices,3choices,4choices or 5choices} the paging interact with each answer as it's a row while I need to deal with it as a group(Question with the Answers) in order to show only 5 questions on each page.

please Advice, Thanks

1 Answers1

0

I solved this problem in easiest way by using

NTILE(10) OVER(ORDER BY QuestionID ASC) AS Pagenumber

in my SQL this will divide all the rows in 10 groups depending on QuestionID

For example :

QUestionID    Pagenumber
QUestionID 11              Pagenumber   1
QUestionID 11                Pagenumber 1
QUestionID 11                Pagenumber 1
QUestionID 11                Pagenumber 1
QUestionID 12                Pagenumber 2
QUestionID 12               Pagenumber  2
QUestionID 30                Pagenumber 3
QUestionID 30                Pagenumber 3
QUestionID 30               Pagenumber  3
QUestionID 44               Pagenumber  4
QUestionID 67               Pagenumber  5
QUestionID 67               Pagenumber  5
QUestionID 67               Pagenumber  5

and so in till I get 10 groups in my page number column

Then on the first call my list view will select * where pagenumber = 1, on second call it will send the page number as query string incremented by 1 so, on second call select * where pagenumber = 2 .. until I reached page 10

I hope that can help someone :)

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459