Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7039249
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:46:29+00:00 2026-05-28T01:46:29+00:00

The web application that I am developing right now has something called quiz engine

  • 0

The web application that I am developing right now has something called quiz engine which provides users with short quizzes which consist of one question or more. Now, I have a problem with the QUIZ page. The quiz may consist of one question or more. The main problem that I have is following: If the quiz consists of one question, when the user comes to this quiz, he will see the NEXT button instead of seeing the FINISHED button. However, if the quiz consists of more than one question, he will see the FINISHED button in the page with the last question. I don’t know why this is happening with me. Any help please?

For creating the Quiz engine, I used the Toturial in the ASP.NET website for creating it.

My ASP.NET code:

<asp:GridView ID="resultGrid" runat="server" DataKeyNames="QuestionID" SelectedIndex="0" 
                    AutoGenerateColumns="False" CellPadding="4" ForeColor="#333333" GridLines="None" AutoGenerateSelectButton="True" OnSelectedIndexChanged="resultGrid_SelectedIndexChanged" Width="555px">
                        <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                        <RowStyle BackColor="#F7F6F3" ForeColor="#333333" CssClass="generaltext" HorizontalAlign="Center" />
                        <Columns>
                            <asp:BoundField DataField="QuestionID" HeaderText="Question" />
                            <%--<asp:BoundField DataField="CorrectAnswer" HeaderText="Correct Answer" />--%>
                            <asp:BoundField DataField="UserAnswer" HeaderText="Your Answer" />
                            <asp:BoundField DataField="Result" HeaderText="Result" />
                        </Columns>
                        <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                        <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                        <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" CssClass="boldtext" />
                        <EditRowStyle BackColor="#999999" />
                        <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                    </asp:GridView>

                    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:testConnectionString %>"
                        SelectCommand="SELECT [Question], [Answer1], [Answer2], [Answer3], [QuestionID], [QuestionOrder], [Answer4], [CorrectAnswer], [AnswerExplanation], [QuizID] FROM [Question] WHERE ([QuizID] = @QuizID) ORDER BY [QuestionOrder]">
                        <SelectParameters>
                            <asp:SessionParameter Name="QuizID" SessionField="QuizID" Type="Int32" />
                        </SelectParameters>
                    </asp:SqlDataSource>  

<asp:DetailsView ID="answerDetails" runat="server" CellPadding="4" ForeColor="#333333"
                        GridLines="None" Height="45px" Width="552px" DataSourceID="SqlDataSource1" 
                        AutoGenerateRows="False" DataKeyNames="QuestionID">

                        <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                        <CommandRowStyle BackColor="#E2DED6" Font-Bold="True" />
                        <RowStyle BackColor="#F7F6F3" ForeColor="#333333" CssClass="generaltext" />
                        <FieldHeaderStyle BackColor="#E9ECF1" Font-Bold="True" CssClass="boldtext" Width="100px" />
                        <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                        <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                        <EditRowStyle BackColor="#999999" />
                        <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                        <Fields>
                            <asp:BoundField DataField="Question" HeaderText="Question" 
                                SortExpression="Question" />
                            <asp:BoundField DataField="Answer1" HeaderText="A" 
                                SortExpression="Answer1" />
                            <asp:BoundField DataField="Answer2" HeaderText="B" 
                                SortExpression="Answer2" />
                            <asp:BoundField DataField="Answer3" HeaderText="C" 
                                SortExpression="Answer3" />
                            <asp:BoundField DataField="Answer4" HeaderText="D" 
                                SortExpression="Answer4" />
                            <asp:BoundField DataField="CorrectAnswer" HeaderText="Correct Answer" 
                                SortExpression="CorrectAnswer" HeaderStyle-BackColor="lightgreen" />
                            <asp:BoundField DataField="AnswerExplanation" HeaderText="Explanation" 
                                SortExpression="AnswerExplanation" HeaderStyle-BackColor="lightgreen" />
                        </Fields>
                    </asp:DetailsView> 

My code-behind:

protected void Page_Load(object sender, EventArgs e)
    {
        questionDetails.DataBind();
    }

    protected void nextButton_Click(object sender, EventArgs e)
    {
        // Save off previous answers
        System.Data.DataRowView dr = (System.Data.DataRowView)questionDetails.DataItem;

        // Create Answer object to save values
        Answer a = new Answer();
        a.QuestionID = dr["QuestionOrder"].ToString();
        a.CorrectAnswer = dr["CorrectAnswer"].ToString();
        a.UserAnswer = answerDropDownList.SelectedValue.ToString();

        ArrayList al = (ArrayList)Session["AnswerList"];
        al.Add(a);

        Session.Add("AnswerList", al);

        if (questionDetails.PageIndex == questionDetails.PageCount - 1)
        {
            // Go to evaluate answers
            Response.Redirect("Results.aspx");
        }
        else
        {
            questionDetails.PageIndex++;
        }

        if (questionDetails.PageIndex == questionDetails.PageCount - 1)
        {
            nextButton.Text = "Finished";
        }

    }

SO HOW TO FIX THIS PROBLEM?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T01:46:29+00:00Added an answer on May 28, 2026 at 1:46 am

    You’re not setting the button text to “Finished” until the nextButton_Click event is fired. Presumably it’s labelled “Next” by default.

    Try this in your Page_Load, or elsewhere before the button click:

    protected void Page_Load(object sender, EventArgs e)     
    {     
        questionDetails.DataBind();  
    
        if (questionDetails.PageCount == 1)       
        {       
            nextButton.Text = "Finished";       
        }   
    }    
    

    This assumes a PageCount of 1 means there’s 1 question.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The web application that I am developing right now has something called quiz engine
The web application that I am developing right now has something called quiz engine
Right now I'm developing the prototype of a web application that aggregates large number
I'm developing a Web application that will let users upload images. My concern is
I'm developing a web application that has to support lots of simultaneous requests, and
I am developing a web application for a comapny. This application provides the users
Right now, I’m working on a legacy web application that is made up of
We are developing and web application which allows users to register for certain events.
I a web application that I am developing (being developed in PHP) when a
I'm using JQuery and Prototype in this web application that I'm developing. I'm looking

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.