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 8961371
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T15:52:33+00:00 2026-06-15T15:52:33+00:00

I’m working on a web based quiz system. I have code that generates an

  • 0

I’m working on a web based quiz system.

I have code that generates an ASP.NET table with a list of questions and radiobutton lists that indicate the answers for the quiz questions.

//Retrieve questions and answers - build the actual quiz
        DataTable dtQuiz = qr.GetQuizQuestions(QuizID);

        if (dtQuiz != null && dtQuiz.Rows.Count >= 1)
        {
            foreach (DataRow row in dtQuiz.Rows)
            {
                TableRow tr = new TableRow();
                TableCell tcQuestionNum = new TableCell();
                TableCell tcQuestion = new TableCell();

                tcQuestionNum.VerticalAlign = VerticalAlign.Top;

                tcQuestionNum.Controls.Add(new LiteralControl(row["QuestionNum"].ToString()));
                tcQuestion.Controls.Add(new LiteralControl(row["Question"].ToString()));

                RadioButtonList rblAnswers = qr.GetAnswers(QuizID, Int32.Parse(row["QuestionNum"].ToString()));
                tcQuestion.Controls.Add(rblAnswers);

                tr.Cells.Add(tcQuestionNum);
                tr.Cells.Add(tcQuestion);

                tblQuiz.Rows.Add(tr);
                tblQuiz.DataBind();
            }
        }

This code generates the content just fine – the quiz questions appear, and the radiobutton lists render as expected.

There’s something weird when I have a separate button click event. After the user selects their answers, I want to do a postback and loop through the rows in the table, pulling the answers from the radiobutton list in the second cell of each row. I started down this path:

        foreach (TableRow tr in tblQuiz.Rows)
    {
        TableCell tc = tr.Cells[1];
        RadioButtonList rbl = (RadioButtonList) tc.Controls[1];
    }

The problem is when the second button is clicked (to post the answers), the table has no rows. Why is this, and how can I correct this?

  • 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-06-15T15:52:34+00:00Added an answer on June 15, 2026 at 3:52 pm

    I can only think of one instance at this time, and that is that you have the code to create the table inside an if (!IsPostBack){} (or If (Not IsPostBack) Then ... if VB)

    If this is the case, your table won’t be created when you postback. You would need to put the code OUTSIDE of the if (!IsPostBack){} so the table gets re-created when you postback.

    UPDATE

    Based on your comment I would suggest:

    Move the code that generates your table to a sub of its own. Something like (in vb)

    Private Sub GenerateTable()
       '' Code here
    End Sub
    

    Then when you click the button to generate the table, Call this sub.

    Finally, when you click the button to submit the answers, call this sub again before processing any of the selections.

    Ultimately, the table needs creating before you can process its contents.

    don’t worry – the creation of the table won’t override any of the selections the user makes.

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

Sidebar

Related Questions

I have a small JavaScript validation script that validates inputs based on Regex. I
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I know there's a lot of other questions out there that deal with this
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example

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.