Solved

Repeater VS Gridview or your opinion

Posted on 2006-11-08
10
1,330 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 

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 500 total points
ID: 17924584
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
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 antispam), the admini…

733 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