0

We need to create a quiz application in SharePoint 2013. We have already created a quiz by write questions in aspx page and writing its code in aspx.cs page and the quiz is running fine.

But the requirement is we need to fetch questions also from SharePoint list and display them and store the answers. The problem we are facing is that we are able to retieve questions but not able to display in the form. Only the final question is getting displayed. It is reading all the questions , but only final question is getting printed. In aspx page we only wrote code for one question and solutions as the code for iteration of the list is written in the cs page. But we are not able to display all the questions in the form.

Can anyone please send the code of aspx and aspx.cs page where we can display the question with 4 radio options of a set of questions?

Thanks in advance.

Screenshot of cs enter image description here

Screenshot of aspx page enter image description here

The output is displayed like the screenshot attached below: enter image description here

3
  • Please add your code, so we can help you more.
    – Milind
    Dec 5, 2019 at 6:20
  • have added the screenshots. Please go through them Dec 5, 2019 at 6:51
  • Please whole foreach loop, it snapshot is crop, so I could not know
    – Milind
    Dec 5, 2019 at 6:57

1 Answer 1

0

Only last question is getting displayed, because your aspx design and code is not correct.

  1. You are looping the code for each item but you do not have that many set of controls in aspx page.
  2. You have only one set of control, which is getting overwritten by last question.

To resolve the issue either:

  1. You will need to add set of controls(question label and radiobuttons) in aspx page similar to no of questions you have
  2. Or create dynamic controls in code for each question-answer and add those control in aspx page using may be panel control
3
  • Can you please let me know a sample code on how to write with by creating dynamic control for the ques-ans in aspx page. I did not find a way in this manner. Thanks a lot. Dec 9, 2019 at 7:09
  • I dont have sample code with me, but I have done this in past and it is achievable, you can search on google.
    – P S
    Dec 9, 2019 at 13:48
  • For e.g. You can keep <asp:table> in aspx page, then create dynamic controls in code and add those controls in row and add that row in table using code.
    – P S
    Dec 9, 2019 at 13:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.