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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T09:49:45+00:00 2026-05-21T09:49:45+00:00

I’m adding a series of dropdown lists populated from a database to a page

  • 0

I’m adding a series of dropdown lists populated from a database to a page from code behind. Because I need a variable number of sections with each containing a variable number of dropdown lists, I’m having to run my queries and then put build and place the HTML straight onto the page. I’m sure there’s a better way to do this (nested repeaters, possibly) but it is working. My HTML is:

Question

<input type='hidden' id='h100' />
   <select id='q100'>
      <option>Answer 1</option>
      <option>Answer 2</option>
      <option>Answer 3</option>
  </select>

However, when the page POSTs back, I’m not getting these fields in the form collection. It’s really odd because they seemed to be there yesterday, but then I come back to the page and can’t find them.

Why would these not be appearing in the form collection after POST?

I’m using C# for code behind, any help is very appreciated.

Edit: Here is my code behind (please don’t hurt me, I’m learning ASP.NET as I go):

if (!Page.IsPostBack)
    {
       // Much stuff that works fine, connecting to database, etc.

            // Get matching questions - variables
            ArrayList matchingSections = new ArrayList();
            int matchingSectionCount;

            // Get count of matching sections 
            OracleCommand cmdMatchSectCount = new OracleCommand("Select Count(distinct matching_section) From graphite.question Join graphite.q_matching Using(q_id) Where t_id = " + Session["TestTaking"].ToString(), conn);
            OracleDataReader drMatchSectCount = cmdMatchSectCount.ExecuteReader();
            drMatchSectCount.Read();
            matchingSectionCount = (int)drMatchSectCount.GetOracleNumber(0).Value;
            Session["MatchingSectionCount"] = matchingSectionCount;

            // Get matching sections
            OracleCommand cmdMatchSects = new OracleCommand("Select Distinct matching_section From graphite.question Join graphite.q_matching Using(q_id) Where t_id = " + Session["TestTaking"].ToString() + " Order By matching_Section", conn);
            OracleDataReader drMatchSects = cmdMatchSects.ExecuteReader();

            for(int i = 0; i < matchingSectionCount; i++)
            {
                drMatchSects.Read();
                matchingSections.Add(drMatchSects.GetOracleString(0).Value);
            }

            foreach (String s in matchingSections)
            {
                string row = string.Empty;
                int questionCount;
                ArrayList answers = new ArrayList();

                matchManual.InnerHtml += "\n<h2>Matching Section - " + s + "</h2>";
                matchManual.InnerHtml += "\n<table>";

                OracleCommand cmdQuestionCount = new OracleCommand("Select Count(correct_answer) From graphite.question Join graphite.q_matching Using(q_id) Where t_id = " + Session["TestTaking"].ToString() + " and matching_section = '" + s + "'", conn);
                OracleDataReader drQuestionCount = cmdQuestionCount.ExecuteReader();
                drQuestionCount.Read();
                questionCount = int.Parse(drQuestionCount.GetOracleNumber(0).Value.ToString());

                OracleCommand cmdMatchAnswers = new OracleCommand("Select correct_answer From graphite.question Join graphite.q_matching Using(q_id) Where t_id = " + Session["TestTaking"].ToString() + " and matching_section = '" + s + "' Order By correct_answer", conn);
                OracleDataReader drMatchAnswers = cmdMatchAnswers.ExecuteReader();
                for (int i = 0; i < questionCount; i++)
                {
                    drMatchAnswers.Read();
                    answers.Add(drMatchAnswers.GetOracleString(0).Value.ToString());
                }

                OracleCommand cmdMatchLoop = new OracleCommand("Select q_phrase, q_id From graphite.question Join graphite.q_matching Using(q_id) Where t_id = " + Session["TestTaking"].ToString() + " and matching_section = '" + s + "'", conn);
                OracleDataReader drMatchLoop = cmdMatchLoop.ExecuteReader();
                for (int i = 0; i < questionCount; i++)
                {
                    drMatchLoop.Read();
                    row += "\n  <tr>";
                    row += "\n    <td>" + drMatchLoop.GetOracleString(0).Value ;

                    row += "<input type='hidden' id='h" + drMatchLoop.GetOracleNumber(1).Value.ToString() + "' />";
                    row += "\n    </td>";
                    row += "\n    <td>";
                    row += "\n      <select id='q" + drMatchLoop.GetOracleNumber(1).Value.ToString() + "' runat='server'>";

                    foreach(string answer in answers)
                    {
                        row += "\n        <option>" + answer + "</option>";
                    }

                    row += "\n      </select>";
                    row += "\n    </td>";

                    row += "\n  </tr>";
                }

                matchManual.InnerHtml += row;
                matchManual.InnerHtml += "\n</table>\n\n";
   }
  • 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-21T09:49:46+00:00Added an answer on May 21, 2026 at 9:49 am

    Wow. Just…wow. With <select>, you have to include a name='value', not id='value'. Moral: know your HTML. And try harder to find ways to avoid spewing raw HTML onto a page.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a bunch of posts stored in text files formatted in yaml/textile (from
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I'm making a simple page using Google Maps API 3. My first. One marker
I need to clean up various Word 'smart' characters in user input, including but

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.