473,386 Members | 1,699 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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)
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>

Nov 19 '05 #1
1 1218
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

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"dinesh" <di****@discussions.microsoft.com> wrote in message
news:AA**********************************@microsof t.com...
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>

Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Stephen Miller | last post by:
I am using the OnItemDataBound event of Repeater control to nest a DataGrid within the Repeater. When I attempt to bind to the DataGrid using the DataSource method I get the error message "Object...
2
by: Colin Nicholls | last post by:
Platform: ASP.NET 1.1 I have a repeater nested inside another repeater. My outer repeater is looping fine. I am manually binding the inner repeater to a DataReader obtained from another...
8
by: I am Sam | last post by:
Hi everyone, This problem is making me old. I don't want to get any older. I have a multi-nested repeater control as follows: <asp:Repeater ID="clubRep1" Runat="server">...
4
by: TheBurgerMan | last post by:
Hi all. I have an array of objects (Let's call it Object A) and each of these objects has an array of other objects (Let's call these Object B) in it. I can successfully repeat through Object A's...
4
by: Antonio Carpentieri | last post by:
Hi all, in my previous post I've wrong typed some tems.. this is the corrected post. in a aspx page I have a repeater like this: <asp:repeater id=repeaterResults runat="server"...
3
by: Iain Buchanan | last post by:
Moving this code below from v1.1 to 2.0... am now getting this bug... After I bind a repeater I move the repeater inside the placeholder using controls.add(), but when I do this, all the...
4
by: Brad Baker | last post by:
I'm going a little crazy :) I'm trying to bind a repeater control to a dataset on page load using the following code: if (Request.QueryString != null) { string customerid = Request.QueryString;...
0
by: uncensored | last post by:
Hello everyone, I'm fairly new at .Net and I have a repeater inside a repeater problem. I will attach my code to this message but basically what I am able to tell when I run my page it tells me...
2
by: dm3281 | last post by:
Hi all -- I have a strange issue. I have obtained a scripted database and compiled ASP.NET 2.0 application from a sister site that I'm trying to implement locally. I have successfully...
2
by: Hong | last post by:
Hi, I have been scratching my head over this problem for hours, the repeater control I am using would only render the controls specified in HeaderTemplate and FooterTemplate, but the repeater...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.