Repeater VS Gridview or your opinion

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
Scripter25Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
darkpriestCommented:
You've blown up your query, Dont use an inner Join
0
 
darkpriestCommented:
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
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
darkpriestCommented:
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
 
Scripter25Author Commented:
I wish you did have more time because ok I will say it.. I am confused
0
 
Scripter25Author Commented:
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
 
darkpriestCommented:
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
 
Scripter25Author Commented:
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
 
Scripter25Author Commented:
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
 
Scripter25Author Commented:
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
All Courses

From novice to tech pro — start learning today.