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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T01:21:10+00:00 2026-06-09T01:21:10+00:00

I have a ListView in the Quiz Management web-based application that I am developing

  • 0

I have a ListView in the Quiz Management web-based application that I am developing and I am binding it to the Answers table in the Database. Now, I want to add a column with a CheckBox control that will be bound to (isCorrect) column in the QuizContent table in the database. I don’t know how to do that, so could you please help me in this?

FYI, I have the following database design:

QuizContent Table: ID, QuizID, QuestionID, AnswerID, isCorrect
Quiz Table: QuizID, Title, Description
Question Table: QuestionID, Question, QuestionOrder, AnswerExplanation
Answers Table: AnswerID, Answer

My ASP.NET code:

<div align="center">
        <asp:ListView ID="ListView3" runat="server" DataSourceID="SqlDataSource3" 
            DataKeyNames="AnswerID" InsertItemPosition="LastItem">

            <EditItemTemplate>

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

                        <asp:ImageButton ID="CancelButton" ImageUrl="Images/icons/cancel324.png" ToolTip="Cancel" runat="server" CommandName="Cancel" />
                    </td>
                    <td>
                        <asp:TextBox ID="AnswerTextBox" runat="server" 
                            Text='<%# Bind("Answer") %>' />
                    </td>
                    <td>
                        <asp:CheckBox ID="CheckBox1" runat="server" AutoPostBack="true"
                            Text='<%# Bind("isCorrect") %>' />
                    </td>
                </tr>
            </EditItemTemplate>

            <EmptyDataTemplate>
                <table id="Table2" runat="server" 
                    style="">
                    <tr>
                        <td>
                            No data was returned.</td>
                    </tr>
                </table>
            </EmptyDataTemplate>

            <InsertItemTemplate>
                <tr style="">
                    <td>
                        <asp:ImageButton ID="InsertButton" ImageUrl="Images/icons/add24.png" ToolTip="Add" runat="server" CommandName="Insert" />

                        <asp:ImageButton ID="CancelButton" ImageUrl="Images/icons/clear24.png" ToolTip="Cancel" runat="server" CommandName="Cancel" />
                    </td>
                    <td>
                        <asp:TextBox ID="AnswerTextBox" runat="server" 
                            Text='<%# Bind("Answer") %>'/>
                    </td>
                    <td>
                        <asp:CheckBox ID="CheckBox1" runat="server" AutoPostBack="true" 
                            Text='<%# Bind("isCorrect") %>' />
                    </td>
                </tr>

            </InsertItemTemplate>

            <ItemTemplate>
                <tr style="">
                    <td>
                        <asp:ImageButton ID="DeleteButton" ImageUrl="Images/icons/delete24.png" ToolTip="Delete" runat="server" CommandName="Delete" />

                        <asp:ImageButton ID="EditButton" ImageUrl="Images/icons/edit24.png" ToolTip="Edit" runat="server" CommandName="Edit" />
                    </td>
                    <td>
                        <asp:Label ID="AnswerLabel" runat="server" Text='<%# Eval("Answer") %>' />
                    </td>
                    <td>
                        <asp:Label ID="IsCorrectLabel" runat="server" Text='<%# Eval("isCorrect") %>' />
                    </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; ">Answer</th>
                            <th style="border-bottom:2px solid #003366; ">is Correct?</th>
                        </tr>
                    </thead>
                    <tbody><tr id="itemPlaceholder" runat="server"></tr></tbody>
                </table></div>
            </LayoutTemplate>
            <SelectedItemTemplate>
                <tr style="">
                    <td>
                        <asp:ImageButton ID="DeleteButton" ImageUrl="Images/icons/delete24.png" ToolTip="Delete" runat="server" CommandName="Delete" />

                        <asp:ImageButton ID="EditButton" ImageUrl="Images/icons/edit24.png" ToolTip="Edit" runat="server" CommandName="Edit" />
                    </td>
                    <td>
                        <asp:Label ID="AnswerLabel" runat="server" 
                            Text='<%# Eval("Answer") %>' />
                    </td>
                    <td>
                        <asp:Label ID="isCorrectLabel" runat="server" 
                            Text='<%# Eval("isCorrect") %>' />
                    </td>
                </tr>
            </SelectedItemTemplate>
        </asp:ListView>
        </div>

        <asp:SqlDataSource ID="SqlDataSource3" runat="server" 
            ConnectionString="<%$ ConnectionStrings:QuizSysDBConnectionString %>" 
            SelectCommand="SELECT        AnswerID, Answer
                            FROM            Answers
                            WHERE        (AnswerID IN
                                                         (SELECT DISTINCT AnswerID
                                                           FROM            QuizContent
                                                           WHERE        (QuestionID = @QuestionID)))"

            DeleteCommand="DELETE FROM [Answers] WHERE [AnswerID] = @AnswerID" 
            InsertCommand="INSERT INTO [Answers] ([Answer]) VALUES (@Answer)" 


            UpdateCommand="UPDATE [Answers] SET [Answer] = @Answer WHERE [AnswerID] = @AnswerID">
                <DeleteParameters>
                    <asp:Parameter Name="AnswerID" Type="Int32" />
                </DeleteParameters>
                <InsertParameters>
                    <asp:Parameter Name="Answer" Type="String" />
                    <asp:ControlParameter ControlID="ListView2" Name="QuestionID" PropertyName="SelectedValue" Type="Int32" />
                </InsertParameters>
                <UpdateParameters>
                    <asp:Parameter Name="Answer" Type="String" />
                </UpdateParameters>

            <SelectParameters>
                <asp:ControlParameter ControlID="ListView2" Name="QuestionID" DefaultValue="0"
                    PropertyName="SelectedValue" Type="Int32" />
            </SelectParameters>
        </asp:SqlDataSource>

Again, my problem is having two different tables in the database. The ListView is bound to the Answer table. And for the CheckBox, it has to be bound to the second table which is the QuizContent, so how to do that?

UPDATE:

Here’s a snapshot to show you what I am missing in the code:
enter image description here

  • 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-09T01:21:12+00:00Added an answer on June 9, 2026 at 1:21 am

    Modifying the query of the SqlDatasource3 does the trick

    enter image description here

            <asp:SqlDataSource ID="SqlDataSource3" runat="server" 
                ConnectionString="<%$ ConnectionStrings:QuizSysDBConnectionString %>" 
                SelectCommand="SELECT        Answers.*, QuizContent.IsCorrect
    FROM            Answers INNER JOIN
                             QuizContent ON Answers.AnswerID = QuizContent.AnswerID
    WHERE        (QuizContent.QuestionID = @QuestionID)"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a ListView that is filled with items of an ArrayAdapter. Now I
I have a ListView that contains 3 checkboxes per row. I want to set
I would have listview and a lot of items inside. I want that user
I have a ListView in WPF that is databound to a basic table that
I have ListView with one column that contains checkboxes <ListView Height=164 HorizontalAlignment=Left ItemsSource={Binding ProductList}
I have a ListView that contains button on each item. I want that the
I want to have one ListView that when I click on the item the
I have ListView that has the following EditItemTemplate: <EditItemTemplate> <tr style=> <td> <asp:LinkButton ID=UpdateButton
I have ListView that uses a GridView to display several columns of data. Two
I have ListView which is saving all data to database. For adding i have

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.