problem using repeater

G

Guest

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)
conPubs.Open()
dtrAuthors = cmdSelect.ExecuteReader()

' Bind to Repeater
Repeater1.DataSource = dtrAuthors
Repeater1.DataBind()

dtrAuthors.Close()
conPubs.Close()
'End If



End Sub

End Class
End Namespace

--------
in the ASP file:


<asp:repeater id="Repeater1" runat="server">
<AlternatingItemTemplate>
<br/>
<%# Container.DataItem( "description" ) %>">
<br/>
</AlternatingItemTemplate>
</asp:repeater>
 
K

Karl Seguin

try:

<%# DataBinder.Eval(Container.DataItem, "description") %>

also, why use the AlternatingItemTemplate instead of the ItemTemplate?
Dunno how that works when you only specify the one rather than the other...

Karl
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,586
Members
45,088
Latest member
JeremyMedl

Latest Threads

Top