[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Repeater VS Gridview or your opinion

Posted on 2006-11-08
10
Medium Priority
?
1,340 Views
Last Modified: 2008-01-09
Hey to save space on here you can see I already have this question posted on a forum with screenshots. please take a look at it and reply in here.

http://forums.asp.net/1458234/ShowThread.aspx#1458234
0
Comment
Question by:Scripter25
  • 5
  • 5
10 Comments
 
LVL 4

Expert Comment

by:darkpriest
ID: 17904079
You've blown up your query, Dont use an inner Join
0
 
LVL 4

Expert Comment

by:darkpriest
ID: 17904083
Sorry one more thing, ive only got a few minutes but try reproducing the data in access and using the query builder, to play with the query if i had time id go into more depth might not get a chance to back to a computer until the weekend, traveling away this week.

0
 
LVL 4

Expert Comment

by:darkpriest
ID: 17904092
Argh 5 more mins..

Split the table up

the answer table that is, your using a query thats listing all possible question answers its why your getting the multiple result your answer relation is correct but make a table

like

QuizQuestions

QuizID QuizQuestionID AnswerID


The answerID would be a fk reference to the answer table
AnswerID Description


On the gridview display quizIDQuestion and the description related and then the related answer description

Thats how i see it anyway good luck! It can be done in gridview
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Scripter25
ID: 17904113
I wish you did have more time because ok I will say it.. I am confused
0
 

Author Comment

by:Scripter25
ID: 17904264
Aight I know you are not going to respond to me anytime soon but reason why I am confused is because you are saying that the query is messed up.

When I test the query out in the SQLDataSource just as the screenshot shows it spits out the correct
0
 
LVL 4

Expert Comment

by:darkpriest
ID: 17923543
Hi Scripter,

I had another quick look, when you say you preview it,  it comes out identical to the way it should?

What are the datamembers and etc.. that you have bound to the table.
0
 

Author Comment

by:Scripter25
ID: 17923775
Ok check this one out. I am sorry but I have already changed the code to using a repeater instead of a DetailsView ( I thought it was a Gridview that should tell you how much knowledge I have on this)

Anyhow. The Repeater works as far as displaying everything I need well actually I had to use 2 repeaters and 2 SQLDataSource's working in conjuction with one another.

Now the Gigantic issue I have is what is happening in the codebehind. With the DetailsView it has paging ability and a few other things that the repeater does not apparently have. This is becoming a big problem now seeing as how the one has backend functions that make the coding easy and the other has front end abilities the other does not.

 What would be the best thing I think for me is if someone had some sites that they could point me to that describe the DetailsView, Repeaters and Gridviews to me in great detail from a beginners level to an advanced level.

So far the most info I have gotten about them is from the Microsoft site which is a good place to look if you just need some refresher info...
0
 

Author Comment

by:Scripter25
ID: 17923782
Here is my ASPX code the whole thing as it stands now.

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="questions.aspx.cs" Inherits="questions" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Quiz - Questions</title>
    <link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <form id="form1" runat="server">
        <table width="560" align="center">
            <tr>
                <td width="100%" align="right" style="height: 21px">
                    <asp:LoginName ID="LoginName1" runat="server" CssClass="boldtext" FormatString="Currently logged in as: {0}" />
                </td>
            </tr>
        </table>    

        <table width="560" align="center">
            <tr>
                <td>
                    <img src="images/quiz.gif" /></td>
            </tr>
            <tr>
                <td>&nbsp;</td>
            </tr>
            <tr>
                <td class="h1">Current Test:&nbsp;
                    <asp:Label ID="currentTestLabel" runat="server"></asp:Label></td>
            </tr>
            <tr>
                <td>&nbsp;<img src="images/line.gif" /></td>
            </tr>                        
            <tr>
                <td>

                    &nbsp;


        <asp:Repeater ID="Repeater2" runat="server" DataSourceID="SqlDataSource2">
            <HeaderTemplate>

                <table border=0 cols=2 Height="50px" Width="550px">
            </HeaderTemplate>

            <ItemTemplate>
                <tr bgcolor=E9ECF1>
                    <td width=12px> Question: </td>
                    <td> <%# Eval("title") %> </td>
                </tr>
            </ItemTemplate>      
        </asp:Repeater>
                    &nbsp; &nbsp;&nbsp;

       

        <asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1">
            <ItemTemplate>
                <tr bgcolor=F7F6F3>
                  <td width=12px> <%# Eval("answerid") %> </td>
                  <td> <%# Eval("answer") %> </td>
                </tr>

            </ItemTemplate>
            <AlternatingItemTemplate>
                <tr bgcolor=white>
                  <td width=12px> <%# Eval("answerid") %> </td>
                  <td> <%# Eval("answer") %> </td>
                </tr>

            </AlternatingItemTemplate>

            <FooterTemplate>

                </table>

            </FooterTemplate>        
        </asp:Repeater>
                    <br />
                    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="SELECT Question.QuizID, Question.QuestionID, Question.Title, Question.CorrectAnswer, Question.QuestionOrder, Answers.Answer, Answers.AnswerID FROM Question INNER JOIN Answers ON Question.QuizID = Answers.QuizID AND Question.QuestionID = Answers.QuestionID WHERE (Question.QuizID = @QuizID) AND (Question.QuestionID = @QuestionID) ORDER BY Question.QuestionOrder">
                        <SelectParameters>
                            <asp:SessionParameter SessionField="QuizID" Type="Int32" Name="QuizID" DefaultValue="0" />
                            <asp:SessionParameter DefaultValue="0" Name="QuestionID" SessionField="QuestionID" />
                        </SelectParameters>
                    </asp:SqlDataSource>
                </td>
            </tr>
            <tr>
                <td>&nbsp;
                    <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
                        SelectCommand="SELECT Title FROM Question WHERE (QuestionID = @QuestionID) AND (QuizID = @QuizID)" OnSelecting="SqlDataSource2_Selecting">
                        <SelectParameters>
                            <asp:SessionParameter DefaultValue="0" Name="QuestionID" SessionField="QuestionID" />
                            <asp:SessionParameter DefaultValue="0" Name="QuizID" SessionField="QuizID" />
                        </SelectParameters>
                    </asp:SqlDataSource>
                </td>
            </tr>
            <tr>
                <td class="boldtext">
                    Your Answer:&nbsp;
                <asp:DropDownList ID="answerDropDownList" runat="server" DataSourceID="SqlDataSource1" DataTextField="AnswerID" DataValueField="AnswerID">
                            <asp:ListItem Value="1">Answer 1</asp:ListItem>
                            <asp:ListItem Value="2">Answer 2</asp:ListItem>
                            <asp:ListItem Value="3">Answer 3</asp:ListItem>
                            <asp:ListItem Value="4">Answer 4</asp:ListItem>
                        </asp:DropDownList>
                </td>
            </tr>
            <tr>
                <td align="right">
                    <asp:Button ID="nextButton" runat="server" OnClick="nextButton_Click" Text="Next" />
                </td>
            </tr>                                    
        </table>
        &nbsp; &nbsp;&nbsp;
    </form>
</body>
</html>
0
 

Author Comment

by:Scripter25
ID: 17923792
Here is my Codebehind as it stands right now even though some of the items dont exactly work due to the change over from detailsview to repeater

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class questions : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Repeater1.DataBind();
        Response.Write("Quiz ID " + Session["QuizID"]);
        Response.Write("Question ID " + Session["QuestionID"]);
    }

    protected void nextButton_Click(object sender, EventArgs e)
    {
        // Save off previous answers
        System.Data.DataRowView dr = (System.Data.DataRowView)Repeater1.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 (Repeater1.PageIndex == Repeater1.PageCount - 1)
        {
            // Go to evaluate answers
            Response.Redirect("results.aspx");
        }
        else
        {
            Repeater1.PageIndex++;
        }

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

    }
    protected void SqlDataSource2_Selecting(object sender, SqlDataSourceSelectingEventArgs e)
    {

    }


}
0
 
LVL 4

Accepted Solution

by:
darkpriest earned 2000 total points
ID: 17924584
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses
Course of the Month20 days, 8 hours left to enroll

868 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question