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