J
John Kotuby
Hi all,
Thanks in advance for any suggestions...
I am using a repeater to display the contents of a DataTable which is bound
to it. All the rows in the table are being displayed. In the OnItemDataBound
event controller in the Code Behind I am formatting the fields returned from
the SQL server select query. The items are formatting correctly, except for
those in the last row of the bound table. To test my theory, I added a row
to the result set, with data that is nearly identical to the row that was
not being formatted. As I expected, the next-to-last row is now being
formatted properly, but the newly added row is not.
Here is the code I am using. Can anyone tell me why the last row of data is
being ignored?
I am defining the format of just the ItemTemplate in the Repeater
declaration HTML.
Note, I am iterating through the RepeaterItemCollection because that is a
code example I saw in a newsgroup and it is the only way I could get at the
particular label (so far). I am guessing there must be a simpler way to get
to a particular label control without searching the entire collection in
the repeater, but I haven't found that code example yet.
--------------------------------
Sub RepSeg_DataBound(ByVal Sender As Object, ByVal e As
RepeaterItemEventArgs)
' This event is raised for the header, the footer, separators, and items.
Dim lblCostFld As Label
Dim rc As RepeaterItemCollection = RepeaterSeg.Items
' Execute the following logic for Items and Alternating Items.
If (e.Item.ItemType = ListItemType.Item) Or _
(e.Item.ItemType = ListItemType.AlternatingItem) Then
For Each Item As RepeaterItem In rc
lblCostFld = CType(Item.FindControl("lblCost"), Label)
If Not lblCostFld Is Nothing Then
segCost = RTrim(lblCostFld.Text)
segCost = Replace(segCost, "/", "")
segCost = Replace(segCost, "M", "")
segCost = FormatCurrency(segCost)
lblCostFld.Text = segCost & "/M"
Else
'*** JPK Debug ***
Response.Write("lblCost field not found")
Response.End()
'*** JPK Debug ***
End If
Next
End If
End Sub
Thanks in advance for any suggestions...
I am using a repeater to display the contents of a DataTable which is bound
to it. All the rows in the table are being displayed. In the OnItemDataBound
event controller in the Code Behind I am formatting the fields returned from
the SQL server select query. The items are formatting correctly, except for
those in the last row of the bound table. To test my theory, I added a row
to the result set, with data that is nearly identical to the row that was
not being formatted. As I expected, the next-to-last row is now being
formatted properly, but the newly added row is not.
Here is the code I am using. Can anyone tell me why the last row of data is
being ignored?
I am defining the format of just the ItemTemplate in the Repeater
declaration HTML.
Note, I am iterating through the RepeaterItemCollection because that is a
code example I saw in a newsgroup and it is the only way I could get at the
particular label (so far). I am guessing there must be a simpler way to get
to a particular label control without searching the entire collection in
the repeater, but I haven't found that code example yet.
--------------------------------
Sub RepSeg_DataBound(ByVal Sender As Object, ByVal e As
RepeaterItemEventArgs)
' This event is raised for the header, the footer, separators, and items.
Dim lblCostFld As Label
Dim rc As RepeaterItemCollection = RepeaterSeg.Items
' Execute the following logic for Items and Alternating Items.
If (e.Item.ItemType = ListItemType.Item) Or _
(e.Item.ItemType = ListItemType.AlternatingItem) Then
For Each Item As RepeaterItem In rc
lblCostFld = CType(Item.FindControl("lblCost"), Label)
If Not lblCostFld Is Nothing Then
segCost = RTrim(lblCostFld.Text)
segCost = Replace(segCost, "/", "")
segCost = Replace(segCost, "M", "")
segCost = FormatCurrency(segCost)
lblCostFld.Text = segCost & "/M"
Else
'*** JPK Debug ***
Response.Write("lblCost field not found")
Response.End()
'*** JPK Debug ***
End If
Next
End If
End Sub