Problem using repeater

Posted on 2005-05-15
Last Modified: 2010-04-07
When I try to display the result of an sql query into a repeater, I get no data. I've tried the query in the analyzer and it works fine. I get no errors from VS. Note for testing purposes the query parameter is now hardcoded.

Imports System.Data.SqlClient
Imports System.Drawing
Imports System.Web
Imports System.Web.SessionState
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.HtmlControls

Namespace findandview

    Public Class resultset
        Inherits System.Web.UI.Page

        Protected WithEvents Repeater1 As System.Web.UI.WebControls.Repeater

#Region " Web Form Designer Generated Code "

        Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            'Put user code to initialize the page here

            'Dim partoftown = Session("partoftown")
            ' Dim partoftown = "kensington"

                Dim conPubs As SqlConnection
                Dim cmdSelect As SqlCommand
                Dim dtrAuthors As SqlDataReader

                ' Retrieve records from database
                conPubs = New SqlConnection("Server=localhost;Trusted_Connection=true;Database=findandview")
                'If partoftown <> "" Then
                'cmdSelect = New SqlCommand("Select description From maintable where area = '" & partoftown & "'", conPubs)
                cmdSelect = New SqlCommand("Select * from maintable where area = 'Kensington'", conPubs)
                dtrAuthors = cmdSelect.ExecuteReader()

                ' Bind to Repeater
                Repeater1.DataSource = dtrAuthors

                'End If

        End Sub

    End Class
End Namespace

in the ASP file:

<asp:repeater id="Repeater1" runat="server">
                              <%# Container.DataItem( "description" ) %>">
Question by:dprasad
    LVL 23

    Expert Comment

    <asp:Repeater Id="Repeater1" runat="server">
    <br />
    <%# DataBinder.Eval(Container.DataItem,"description") %>
    <br />
    LVL 23

    Accepted Solution

    Your code means that every odd record will not be shown. So if there is only one record it wont be shown.

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Join & Write a Comment

    In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
    One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on could not pull conte…
    This video discusses moving either the default database or any database to a new volume.
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    734 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

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now