Repeater displaying dataset rows multiple times

E

Erik

I have the following code for a dynamic Repeater. This is my first time
using a Repeater. The issue I run into is the rows from the dataset are
being displayed multiple times. For example, if there are 2 rows in the
dataset, the rows are displayed twice. If there are 15 rows in the dataset,
the rows are displayed 15 times. Please provide an explanation as to why
this is happening, and a working solution. Thanks you.

HTML:
<asp:Repeater id="DetailRepeater" runat="server"></asp:Repeater>

VB.Net code:
Dim dc As DataColumn
Dim dr As DataRow
Dim rpthdr As New TemplateBuilder
Dim rptitem As New TemplateBuilder
Dim rptftr As New TemplateBuilder
Dim strval As String

strval = "<TABLE width='1200'><tr Class='ms-formlabel
DataListFixedHeader'>"

For Each dc In oData.Tables(0).Columns
strval &= "<td align='center' Class='TDBorderBottom'><b>" &
dc.ColumnName & "</b></td>"
Next

strval &= "</tr>"

rpthdr.AppendLiteralString(strval)
DetailRepeater.HeaderTemplate = rpthdr

strval = ""

Dim i As Integer
Dim currRows() As DataRow = oData.Tables(0).Select(Nothing, Nothing,
DataViewRowState.CurrentRows)

For Each dr In currRows
strval &= "<tr>"
For i = 0 To oData.Tables(0).Columns.Count - 1
strval &= "<td Class='ASPLabel'>" & dr(i).ToString.Trim() &
"</td>"
Next
strval &= "</tr>"
Next

rptitem.AppendLiteralString(strval)
DetailRepeater.ItemTemplate = rptitem

strval = "</TABLE>"

rptftr.AppendLiteralString(strval)
DetailRepeater.FooterTemplate = rptftr

DetailRepeater.DataSource = oData
DetailRepeater.DataBind()
 

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

Similar Threads

repeater 0
Delete rows in Gridview 0
Nested Repeater 0
delete rows in dataset 1
Nested Repeater within Grid 0
Iterate through table rows 5
Possible ASP.NET Repeater bugs 0
Repeater Issue 4

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top