Trying to access previous item in listview during itemDatabound but it returns nothing. In fact, lvListview.items.count is showing 0; even though the records are clearly there.
Thank you of course for any help. :)
Protected Sub lvReleaseNotesReport_ItemDataBound(sender As Object, e As ListViewItemEventArgs) Handles lvReleaseNotesReport.ItemDataBound
If e.Item.ItemType = ListViewItemType.DataItem Then
Dim relNote As ReleaseNotesDTO = DirectCast(e.Item.DataItem, ReleaseNotesDTO)
If e.Item.DataItemIndex > 0 Then
Dim prevNote As ReleaseNotesDTO = DirectCast(lvReleaseNotesReport.Items(e.Item.DataItemIndex - 1).DataItem, ReleaseNotesDTO)
'prevNote keeps coming up as Nothing
End If
'do other stuff with relNote and prevNote...
End If
End Sub
Tried this as well,...
Protected Sub lvReleaseNotesReport_PreRender(sender As Object, e As EventArgs) Handles lvReleaseNotesReport.PreRender
For Each item As ListViewItem In lvReleaseNotesReport.Items
If item.ItemType = ListViewItemType.DataItem Then
If item.DataItemIndex > 0 Then
Dim thisNote As ReleaseNotesDTO = DirectCast(item.DataItem, ReleaseNotesDTO)
Dim prevItem As ListViewDataItem = lvReleaseNotesReport.Items(item.DataItemIndex - 1)
Dim prevNote As ReleaseNotesDTO = DirectCast(prevItem.DataItem, ReleaseNotesDTO)
'do other stuff with relNote and prevNote...
End If
End If
Next
End Sub
While stepping through code, mousing over lvReleaseNotesReport.Items shows the correct record count, but all dataitems are = nothing.
Thanks anyway, I figured it out. DataKeyNames and DataKeys index.