?
Solved

Repeater VS Gridview or your opinion

Posted on 2006-11-08
10
Medium Priority
?
1,334 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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

Technology Partners: 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!

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Suggested Courses

771 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