473,666 Members | 2,144 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Repeater. I see only the last record. Have no idea why!



Hello,

I am created an Asp.Net 2.0 repeater implementing the ITemplate class.

I know my datasource, a datatable has 6 rows, but the repeater only
displays the last one.

If I add more rows to my datatable I keep seeing only the last record
on my repeater. any idea why?

This is my ITemplate code:

1
2 Private Class rFeedbackTempla te
3 Implements ITemplate
4
5 Private Type As ListItemType
6 Protected WithEvents lMessage As New Label
7
8 Public Sub New(ByVal type As ListItemType)
9 Me.Type = type
10 End Sub ' New
11
12 ' InstantiateIn
13 Public Sub InstantiateIn(B yVal container As Control)
Implements ITemplate.Insta ntiateIn
14 Select Case Me.Type
15 Case ListItemType.He ader ' Header
template
16 Case ListItemType.It em ' Item
template
17 container.Contr ols.Add(lMessag e)
18 Case ListItemType.Al ternatingItem ' Alternating
item template
19 Case ListItemType.Fo oter ' Footer
template
20 End Select
21 End Sub ' InstantiateIn
22
23 Private Sub lMessage_DataBi nding(ByVal sender As Object,
ByVal e As System.EventArg s) Handles lMessage.DataBi nding
24 Dim container As RepeaterItem =
CType(lMessage. NamingContainer , RepeaterItem)
25 lMessage.Text = DataBinder.Eval (container.Data Item,
"Message")
26 End Sub ' lMessage_DataBi nding
27
28 Private Sub lMessage_Init(B yVal sender As Object, ByVal e
As EventArgs) Handles lMessage.Init
29 With lMessage
30 .CssClass = "lMessage"
31 .ID = "lMessage"
32 End With
33 End Sub ' lMessage_Init
34
35 End Class ' rFeedbackTempla te

My repeater events:

1
2 Private Sub rFeedback_Init( ByVal sender As Object, ByVal e As
System.EventArg s) Handles rFeedback.Init
3 rFeedback.ID = "rFeedback"
4 rFeedback.ItemT emplate = New
rFeedbackTempla te(ListItemType .Item)
5 End Sub ' rFeedback_Init
6
7 Private Sub rFeedback_Load( ByVal sender As Object, ByVal e As
System.EventArg s) Handles rFeedback.Load
8 If Not Page.IsPostBack Then
9 With rFeedback
10 .DataSource = rFeedback_DataS ource()
11 .DataBind()
12 End With
13 End If
14 End Sub ' rFeedback_Load
15
16 ' rFeedback_DataS ource
17 Private Function rFeedback_DataS ource() As DataTable
18 Dim dtFeedback As New DataTable
19 dtFeedback.Colu mns.Add(New DataColumn("Mes sage",
GetType(String) ))
20 For Each message As String In Me.Messages
21 Dim drFeedback As DataRow = dtFeedback.NewR ow
22 drFeedback("Mes sage") = message
23 dtFeedback.Rows .Add(drFeedback )
24 Next message
25 Return dtFeedback
26 End Function ' rFeedback_DataS ource

Any idea why I only see the last record of my data source in my
repeater?

Thanks,

Miguel

Feb 26 '07 #1
3 2071
Show us your SQL statement

--
David Wier
MVP/ASPInsider
http://aspnet101.com
http://aspexpress.com
"shapper" <md*****@gmail. comwrote in message
news:11******** *************@z 35g2000cwz.goog legroups.com...
>

Hello,

I am created an Asp.Net 2.0 repeater implementing the ITemplate class.

I know my datasource, a datatable has 6 rows, but the repeater only
displays the last one.

If I add more rows to my datatable I keep seeing only the last record
on my repeater. any idea why?

This is my ITemplate code:

1
2 Private Class rFeedbackTempla te
3 Implements ITemplate
4
5 Private Type As ListItemType
6 Protected WithEvents lMessage As New Label
7
8 Public Sub New(ByVal type As ListItemType)
9 Me.Type = type
10 End Sub ' New
11
12 ' InstantiateIn
13 Public Sub InstantiateIn(B yVal container As Control)
Implements ITemplate.Insta ntiateIn
14 Select Case Me.Type
15 Case ListItemType.He ader ' Header
template
16 Case ListItemType.It em ' Item
template
17 container.Contr ols.Add(lMessag e)
18 Case ListItemType.Al ternatingItem ' Alternating
item template
19 Case ListItemType.Fo oter ' Footer
template
20 End Select
21 End Sub ' InstantiateIn
22
23 Private Sub lMessage_DataBi nding(ByVal sender As Object,
ByVal e As System.EventArg s) Handles lMessage.DataBi nding
24 Dim container As RepeaterItem =
CType(lMessage. NamingContainer , RepeaterItem)
25 lMessage.Text = DataBinder.Eval (container.Data Item,
"Message")
26 End Sub ' lMessage_DataBi nding
27
28 Private Sub lMessage_Init(B yVal sender As Object, ByVal e
As EventArgs) Handles lMessage.Init
29 With lMessage
30 .CssClass = "lMessage"
31 .ID = "lMessage"
32 End With
33 End Sub ' lMessage_Init
34
35 End Class ' rFeedbackTempla te

My repeater events:

1
2 Private Sub rFeedback_Init( ByVal sender As Object, ByVal e As
System.EventArg s) Handles rFeedback.Init
3 rFeedback.ID = "rFeedback"
4 rFeedback.ItemT emplate = New
rFeedbackTempla te(ListItemType .Item)
5 End Sub ' rFeedback_Init
6
7 Private Sub rFeedback_Load( ByVal sender As Object, ByVal e As
System.EventArg s) Handles rFeedback.Load
8 If Not Page.IsPostBack Then
9 With rFeedback
10 .DataSource = rFeedback_DataS ource()
11 .DataBind()
12 End With
13 End If
14 End Sub ' rFeedback_Load
15
16 ' rFeedback_DataS ource
17 Private Function rFeedback_DataS ource() As DataTable
18 Dim dtFeedback As New DataTable
19 dtFeedback.Colu mns.Add(New DataColumn("Mes sage",
GetType(String) ))
20 For Each message As String In Me.Messages
21 Dim drFeedback As DataRow = dtFeedback.NewR ow
22 drFeedback("Mes sage") = message
23 dtFeedback.Rows .Add(drFeedback )
24 Next message
25 Return dtFeedback
26 End Function ' rFeedback_DataS ource

Any idea why I only see the last record of my data source in my
repeater?

Thanks,

Miguel

Feb 26 '07 #2
There is no "SQL Statement" for him to show you. Go back and look at his code.
--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"David Wier" wrote:
Show us your SQL statement

--
David Wier
MVP/ASPInsider
http://aspnet101.com
http://aspexpress.com
"shapper" <md*****@gmail. comwrote in message
news:11******** *************@z 35g2000cwz.goog legroups.com...


Hello,

I am created an Asp.Net 2.0 repeater implementing the ITemplate class.

I know my datasource, a datatable has 6 rows, but the repeater only
displays the last one.

If I add more rows to my datatable I keep seeing only the last record
on my repeater. any idea why?

This is my ITemplate code:

1
2 Private Class rFeedbackTempla te
3 Implements ITemplate
4
5 Private Type As ListItemType
6 Protected WithEvents lMessage As New Label
7
8 Public Sub New(ByVal type As ListItemType)
9 Me.Type = type
10 End Sub ' New
11
12 ' InstantiateIn
13 Public Sub InstantiateIn(B yVal container As Control)
Implements ITemplate.Insta ntiateIn
14 Select Case Me.Type
15 Case ListItemType.He ader ' Header
template
16 Case ListItemType.It em ' Item
template
17 container.Contr ols.Add(lMessag e)
18 Case ListItemType.Al ternatingItem ' Alternating
item template
19 Case ListItemType.Fo oter ' Footer
template
20 End Select
21 End Sub ' InstantiateIn
22
23 Private Sub lMessage_DataBi nding(ByVal sender As Object,
ByVal e As System.EventArg s) Handles lMessage.DataBi nding
24 Dim container As RepeaterItem =
CType(lMessage. NamingContainer , RepeaterItem)
25 lMessage.Text = DataBinder.Eval (container.Data Item,
"Message")
26 End Sub ' lMessage_DataBi nding
27
28 Private Sub lMessage_Init(B yVal sender As Object, ByVal e
As EventArgs) Handles lMessage.Init
29 With lMessage
30 .CssClass = "lMessage"
31 .ID = "lMessage"
32 End With
33 End Sub ' lMessage_Init
34
35 End Class ' rFeedbackTempla te

My repeater events:

1
2 Private Sub rFeedback_Init( ByVal sender As Object, ByVal e As
System.EventArg s) Handles rFeedback.Init
3 rFeedback.ID = "rFeedback"
4 rFeedback.ItemT emplate = New
rFeedbackTempla te(ListItemType .Item)
5 End Sub ' rFeedback_Init
6
7 Private Sub rFeedback_Load( ByVal sender As Object, ByVal e As
System.EventArg s) Handles rFeedback.Load
8 If Not Page.IsPostBack Then
9 With rFeedback
10 .DataSource = rFeedback_DataS ource()
11 .DataBind()
12 End With
13 End If
14 End Sub ' rFeedback_Load
15
16 ' rFeedback_DataS ource
17 Private Function rFeedback_DataS ource() As DataTable
18 Dim dtFeedback As New DataTable
19 dtFeedback.Colu mns.Add(New DataColumn("Mes sage",
GetType(String) ))
20 For Each message As String In Me.Messages
21 Dim drFeedback As DataRow = dtFeedback.NewR ow
22 drFeedback("Mes sage") = message
23 dtFeedback.Rows .Add(drFeedback )
24 Next message
25 Return dtFeedback
26 End Function ' rFeedback_DataS ource

Any idea why I only see the last record of my data source in my
repeater?

Thanks,

Miguel


Feb 26 '07 #3
On Feb 26, 8:10 pm, Peter Bromberg [C# MVP]
<pbromb...@yaho o.yabbadabbadoo .comwrote:
There is no "SQL Statement" for him to show you. Go back and look at his code.
--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net

"David Wier" wrote:
Show us your SQL statement
--
David Wier
MVP/ASPInsider
http://aspnet101.com
http://aspexpress.com
"shapper" <mdmo...@gmail. comwrote in message
news:11******** *************@z 35g2000cwz.goog legroups.com...
Hello,
I am created an Asp.Net 2.0 repeater implementing the ITemplate class.
I know my datasource, a datatable has 6 rows, but the repeater only
displays the last one.
If I add more rows to my datatable I keep seeing only the last record
on my repeater. any idea why?
This is my ITemplate code:
1
2 Private Class rFeedbackTempla te
3 Implements ITemplate
4
5 Private Type As ListItemType
6 Protected WithEvents lMessage As New Label
7
8 Public Sub New(ByVal type As ListItemType)
9 Me.Type = type
10 End Sub ' New
11
12 ' InstantiateIn
13 Public Sub InstantiateIn(B yVal container As Control)
Implements ITemplate.Insta ntiateIn
14 Select Case Me.Type
15 Case ListItemType.He ader ' Header
template
16 Case ListItemType.It em ' Item
template
17 container.Contr ols.Add(lMessag e)
18 Case ListItemType.Al ternatingItem ' Alternating
item template
19 Case ListItemType.Fo oter ' Footer
template
20 End Select
21 End Sub ' InstantiateIn
22
23 Private Sub lMessage_DataBi nding(ByVal sender As Object,
ByVal e As System.EventArg s) Handles lMessage.DataBi nding
24 Dim container As RepeaterItem =
CType(lMessage. NamingContainer , RepeaterItem)
25 lMessage.Text = DataBinder.Eval (container.Data Item,
"Message")
26 End Sub ' lMessage_DataBi nding
27
28 Private Sub lMessage_Init(B yVal sender As Object, ByVal e
As EventArgs) Handles lMessage.Init
29 With lMessage
30 .CssClass = "lMessage"
31 .ID = "lMessage"
32 End With
33 End Sub ' lMessage_Init
34
35 End Class ' rFeedbackTempla te
My repeater events:
1
2 Private Sub rFeedback_Init( ByVal sender As Object, ByVal e As
System.EventArg s) Handles rFeedback.Init
3 rFeedback.ID = "rFeedback"
4 rFeedback.ItemT emplate = New
rFeedbackTempla te(ListItemType .Item)
5 End Sub ' rFeedback_Init
6
7 Private Sub rFeedback_Load( ByVal sender As Object, ByVal e As
System.EventArg s) Handles rFeedback.Load
8 If Not Page.IsPostBack Then
9 With rFeedback
10 .DataSource = rFeedback_DataS ource()
11 .DataBind()
12 End With
13 End If
14 End Sub ' rFeedback_Load
15
16 ' rFeedback_DataS ource
17 Private Function rFeedback_DataS ource() As DataTable
18 Dim dtFeedback As New DataTable
19 dtFeedback.Colu mns.Add(New DataColumn("Mes sage",
GetType(String) ))
20 For Each message As String In Me.Messages
21 Dim drFeedback As DataRow = dtFeedback.NewR ow
22 drFeedback("Mes sage") = message
23 dtFeedback.Rows .Add(drFeedback )
24 Next message
25 Return dtFeedback
26 End Function ' rFeedback_DataS ource
Any idea why I only see the last record of my data source in my
repeater?
Thanks,
Miguel
Hi,

I don't have an SQL statement.

This code is inside an user control.

The user control as a property as follows:

' Messages
Private _Messages As New Generic.List(Of String)
Public Property Messages() As Generic.List(Of String)
Get
Return _Messages
End Get
Set(ByVal value As Generic.List(Of String))
_Messages = value
End Set
End Property ' Messages

On my page I have something like:
With MyUserControl.M essages
.Add("Message01 ")
.Add("Message02 ")
...
.Add("Message06 ")
End With

On my UserControl, inside rFeedback_DataS ource, I place the following
code:
Response.Write( dtFeedback.Rows .Count.ToString )

I get 6!

I looked everywhere, all day, to try to figure out what is going on
but I have no idea.

Could someone, please help me out?

Thanks,
Miguel

Feb 27 '07 #4

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

Similar topics

1
12036
by: Josh Daws | last post by:
Hi, I'm just learning asp.net. I'm very familiar with asp and coldfusion, but I'm getting very frustrated learning asp.net. I'm working on my first project. Basically just converting a coldfusion site to asp.net Here's what I need to do. I have a repeater that is displaying a list of records from the db. I need the first item and the last item displayed to be designated as first and last. Is this possible? I know I can use...
3
4375
by: francois | last post by:
Hi, I have a little problem I am using a stored procedure to retrieve my date. What I want to achieve is to be able to "skip" some row from the resultset i retrieve back from the stored procedure. To be clear, when I Bind my repeater I want to be able to skip some records in my repeater and not display anything at all for that record. I do some calculation on the data i retrieve to decide if i will bind that row or not.
1
3186
by: darrel | last post by:
I'm trying to whip up a fancy repeater control that will put records into a two-column table for me. This is how I envision it working: itemtemplate if record count = odd then write out the TR tag td <record> /td if record count = even then wrote out the /TR tag if record count = odd AND it's the last record, write out an empty TD and
3
2853
by: WebMatrix | last post by:
I am struggling with implementing somewhat complicated UI web-control. I explored Repeater, but I am not sure if it's the best way to go. I am leaning towards writing my own custom control and creating elements on the fly dynamically. I have a control that needs to display 3 columns and n number of rows depending on number of records. Sounds simple. But each Row has a control with its own data source binding and value must be selected...
1
1190
by: Shapper | last post by:
Hello, I am trying to get some data from a XML file into a repeater: MyXML.ReadXml("http://www.mydomain.com/myXmlFile.xml") MyRepeater.DataSource = MyXML MyRepeater.DataBind() My XML file is something like this:
3
2103
by: Andrew | last post by:
Hi, I am working on a questionnaire. I have displayed a questionnaire using a repeater control. The itemtemplate is as below (quite cut down): <ItemTemplate> <tr><td> <%# DataBinder.Eval(Container.DataItem, "question")%> </td></tr> <tr><td>
2
5094
by: shapper | last post by:
Hello, I created a Repeater at runtime with an AccessDataSource.Everything Works fine! Now I need to use the same repeater but with a DataSource created in my VB.Net code. I created a DataView but the Repeater doesn't show anything! I don't get any error so I have no idea what is going on.
1
4341
by: Dave A | last post by:
I have a problem that I have boiled down to a very simple example. I have a user control that displays a some data from a business object. On one screen I have a collection of these business objects and wish to display the user control multiple times. On this web page I simply bind the repeater to the data source and in the ItemDataBound event dynamically load the user control via "LoadControl()". The user control contains an auto post...
2
7072
by: shapper | last post by:
Hello, I am binding a Repeater as follows: Private Sub rFeedback_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles rFeedback.Load If Not Page.IsPostBack Then rFeedback.DataSource = "rFeedback_DataSource" rFeedback.DataBind()
0
8869
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8781
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8551
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7386
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6198
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5664
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4368
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2011
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1775
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.