Problem using repeater

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" ) %>">
Who is Participating?
Your code means that every odd record will not be shown. So if there is only one record it wont be shown.
<asp:Repeater Id="Repeater1" runat="server">
<br />
<%# DataBinder.Eval(Container.DataItem,"description") %>
<br />
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.