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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T22:34:07+00:00 2026-06-07T22:34:07+00:00

I am a new ASP.NET developer and I am trying to develop a simple

  • 0

I am a new ASP.NET developer and I am trying to develop a simple Quiz Engine that will allow the System Administrator to create quizzes. What I did is the following: I created a ListView for inserting the Quiz title and description, and for the content of the quiz itself like the questions and the answers, I have a big problem with that. Since each quiz has different number of questions. And each question has different number of answers since the question could be multiple choice question with four answers and it could be True of False question. So what is the best why to accomodate all of these requirements.? Any idea? And could you please provide me with example or a code snippet?

FYI, I have the following database design:

Quiz Table: QuizID, Title, Description
Question Table: QuestionID, Question, QuestionOrder, AnswerExplanation
QuestionImage Table: ID, QuestionID, URL
Answer Table: AnswerID, Answer
QuizContent Table: ID, QuizID, QuestionID, AnswerID

My ASP.NET code:

<div align="center">
            <asp:ListView ID="ListView1" runat="server" DataKeyNames="QuizID" 
                DataSourceID="SqlDataSource1" InsertItemPosition="LastItem" >

                <EditItemTemplate>
                    <tr style="">
                        <td>
                            <asp:ImageButton ID="UpdateButton" ImageUrl="Images/icons/update24.png" Width="20px" runat="server" CommandName="Update" />

                            <asp:ImageButton ID="CancelButton" ImageUrl="Images/icons/cancel324.png" Width="20px" runat="server" CommandName="Cancel" />
                        </td>
                        <td>
                            <asp:TextBox ID="TitleTextBox" runat="server" Text='<%# Bind("Title") %>' />
                        </td>
                        <td>
                            <asp:TextBox ID="DescriptionTextBox" runat="server" 
                                Text='<%# Bind("Description") %>' />
                        </td>
                    </tr>
                </EditItemTemplate>
                <EmptyDataTemplate>
                    <table id="Table1" runat="server" style="">
                        <tr>
                            <td>
                                No data was returned.</td>
                        </tr>
                    </table>
                </EmptyDataTemplate>
                <InsertItemTemplate>
                    <tr style="">
                        <td>
                            <asp:ImageButton ID="InsertButton" ImageUrl="Images/icons/create 2 48.png" Width="20px" runat="server" CommandName="Insert" />

                            <asp:ImageButton ID="CancelButton" ImageUrl="images/clear3.png" Width="20px" runat="server" CommandName="Cancel" />
                        </td>

                        <%--<td>
                            &nbsp;</td>--%>
                        <td>
                            <asp:TextBox ID="TitleTextBox" runat="server" Text='<%# Bind("Title") %>' />
                        </td>
                        <td>
                            <asp:TextBox ID="DescriptionTextBox" runat="server" 
                                Text='<%# Bind("Description") %>' />
                        </td>
                    </tr>
                </InsertItemTemplate>
                <ItemTemplate>
                    <tr style="">
                        <td>
                            <asp:ImageButton ID="DeleteButton" ImageUrl="Images/icons/delete24.png" Width="20px" runat="server" CommandName="Delete" />

                            <asp:ImageButton ID="EditButton" ImageUrl="Images/icons/edit224.png" Width="20px" runat="server" CommandName="Edit" />

                            <asp:ImageButton ID="SelectButton" ImageUrl="images/select.png" Width="20px" runat="server" CommandName="Select" />
                            <%--<asp:Button ID="SelectButton" runat="server" CommandName="Select" Text="Select" />--%>
                        </td>
                        <%--<td>
                            <asp:Label ID="QuizIDLabel" runat="server" 
                                Text='<%# Eval("QuizID") %>' />
                        </td>--%>
                        <td>
                            <asp:Label ID="TitleLabel" runat="server" Text='<%# Eval("Title") %>' />
                        </td>
                        <td>
                            <asp:Label ID="DescriptionLabel" runat="server" 
                                Text='<%# Eval("Description") %>' />
                        </td>
                    </tr>
                </ItemTemplate>
                <LayoutTemplate>
                    <div ><table id="thetable" width="97%" cellpadding="0px" cellspacing="0px" style="margin:0px 0px 0px 0px; border:2px solid #003366; font-size:13px; font-weight:bold;">
                        <thead>
                            <tr style="background-color:#C6D7B5;">
                                <th style="border-bottom:2px solid #003366; ">...</th>
                                <th style="border-bottom:2px solid #003366; ">Title</th>
                                <th style="border-bottom:2px solid #003366; ">Description</th>
                            </tr>
                       </thead>
                       <tbody><tr id="itemPlaceholder" runat="server"></tr></tbody>
                    </table></div>
                </LayoutTemplate>
                <SelectedItemTemplate>
                    <tr style="">
                        <td>
                            <asp:ImageButton ID="DeleteButton" ImageUrl="images/delete24.png" Width="20px" runat="server" CommandName="Delete" />

                            <asp:ImageButton ID="EditButton" ImageUrl="images/edit224.png" Width="20px" runat="server" CommandName="Edit" />
                        </td>
                        <%--<td>
                            <asp:Label ID="QuizIDLabel" runat="server" 
                                Text='<%# Eval("QuizID") %>' />
                        </td>--%>
                        <td>
                            <asp:Label ID="TitleLabel" runat="server" Text='<%# Eval("Title") %>' />
                        </td>
                        <td>
                            <asp:Label ID="DescriptionLabel" runat="server" 
                                Text='<%# Eval("Description") %>' />
                        </td>
                    </tr>
                </SelectedItemTemplate>
            </asp:ListView>
            <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
                ConnectionString="<%$ ConnectionStrings:QuizSysDBConnectionString %>" 

                SelectCommand="SELECT * FROM [Quiz]" 
                DeleteCommand="DELETE FROM [Quiz] WHERE [QuizID] = @QuizID" 
                InsertCommand="INSERT INTO [Quiz] ([Title], [Description]) VALUES (@Title, @Description)" 


                UpdateCommand="UPDATE [Quiz] SET [Title] = @Title, [Description] = @Description WHERE [QuizID] = @QuizID">
                <DeleteParameters>
                    <asp:Parameter Name="QuizID" Type="Int32" />
                </DeleteParameters>
                <InsertParameters>
                    <asp:Parameter Name="Title" Type="String" />
                    <asp:Parameter Name="Description" Type="String" />
                </InsertParameters>
                <UpdateParameters>
                    <asp:Parameter Name="Title" Type="String" />
                    <asp:Parameter Name="Description" Type="String" />
                    <asp:Parameter Name="QuizID" Type="Int32" />
                </UpdateParameters>
            </asp:SqlDataSource>
    </div>

UPDATE:

I am trying to make the quiz engine dynamic as much as possible. Since I have different number of possible answers for each question, I want the user to enter the number of answers first, and the textboxes will be created for him. I already wrote the code but it did not work. There is no error but there is no TextBoxes created for me. So how to do that?

My ASP.NET code (I created a panel but I never used it):

<div>
        <asp:Label ID="lblText" runat="server" Text="How many answers?" />
        <asp:TextBox ID="NumOfTextBoxes" runat="server"></asp:TextBox>
        <asp:Button ID="insertAnswerTextBox" runat="server" Text="Enter" OnClick="insertAnswerTextBox_OnClick" />

        <asp:Panel ID="AnswersForm" runat="server" Visible="false">
            <asp:TextBox ID="AnswerTextBox" runat="server"></asp:TextBox>
        </asp:Panel>
    </div>

Code-Behind:

protected void insertAnswerTextBox_OnClick(object sender, EventArgs e)
    {
        PlaceHolder PlaceHolder1 = new PlaceHolder();
        // Get the number of textbox to create.
        int number = System.Convert.ToInt32(NumOfTextBoxes.Text);
        for (int i = 1; i <= number; i++)
        {
            TextBox AnswerTextBox = new TextBox();

            // Set the label's Text and ID properties.
            AnswerTextBox.Text = "AnswerTxtBox" + i.ToString();
            AnswerTextBox.ID = "AnswerTxtBox" + i.ToString();
            PlaceHolder1.Controls.Add(AnswerTextBox);
            // Add a spacer in the form of an HTML <br /> element.
            PlaceHolder1.Controls.Add(new LiteralControl("<br />"));
        }
    }
  • 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-07T22:34:09+00:00Added an answer on June 7, 2026 at 10:34 pm

    Your code is correct except one thing you forgot to add. You added all the textboxes to the placeholder control but you have not added place holder to your web form. Add the following line to your insertAnswerTextBox_OnClick.

      form1.Controls.Add(PlaceHolder1); 
    

    Complete code should look like this

    protected void insertAnswerTextBox_OnClick(object sender, EventArgs e)
    {
        PlaceHolder PlaceHolder1 = new PlaceHolder();
        // Get the number of textbox to create.
        int number = System.Convert.ToInt32(NumOfTextBoxes.Text);
        for (int i = 1; i <= number; i++)
        {
            TextBox AnswerTextBox = new TextBox();
    
            // Set the label's Text and ID properties.
            AnswerTextBox.Text = "AnswerTxtBox" + i.ToString();
            AnswerTextBox.ID = "AnswerTxtBox" + i.ToString();
            PlaceHolder1.Controls.Add(AnswerTextBox);
            // Add a spacer in the form of an HTML <br /> element.
            PlaceHolder1.Controls.Add(new LiteralControl("<br />"));
        }
        form1.Controls.Add(PlaceHolder1); 
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am a New ASP.NET Developer and I am trying to develop a simple
I'm planning a new ASP.NET project that will become a product that is installed
I'm totally rewriting the question.. I'm new to ASP.Net, and trying to develop a
I'm new to asp.net, mvc3 and entity framework. I'm trying to develop a mvc3
I am trying to develop an asp.net site with multiple subdomains. I am new
I am a new ASP.NET developer and I am trying to change the value
I'm new to ASP.NET (I'm a PHP developer) and I'm trying to understand how
I'm trying to develop an ASP.net site that reads the clientCertificate to ensure a
I am a new ASP.NET developer and trying to use ASP.NET Ajax BallouPopupExtender with
I am a new ASP.NET developer and trying to use a GridView control to

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.