Deleting the first item in a List


Author
Message
Charles Thomas Blankenship...
Charles Thomas Blankenship
StrataFrame User (448 reputation)StrataFrame User (448 reputation)StrataFrame User (448 reputation)StrataFrame User (448 reputation)StrataFrame User (448 reputation)StrataFrame User (448 reputation)StrataFrame User (448 reputation)StrataFrame User (448 reputation)StrataFrame User (448 reputation)
Group: Awaiting Activation
Posts: 172, Visits: 12K
Everytime I delete the first item in my list I get the following error:





The CurrentRow could not be evaluated because the CurrentRowIndex is out of range. Business object record count: 7. CurrentRowIndex: -1.



A closer evaluation of the code shows the following issue ... when the list is at the first item ... the _CurrentRowIndex is already at 0 ... the -= 1 changes this to a negative one which throws the error above. Should I put a check in there to see if the _CurrentrowIndex is already 0 before decrementing?





If loCurrentPk.Equals(PKValue) Then

'-- Remove the current row and navigate to the next row

loRow = Me.CurrentRow

loRow.Delete()

loRow.AcceptChanges()



'-- Decrement the index and navigate

Me._CurrentRowIndex -= 1

Me.Navigate(BusinessNavigationDirection.Next)

Else

'-- Find the row to delete

If Me.SeekToPrimaryKey(PKValue) Then

'-- Remove the row

loRow = Me.CurrentRow

loRow.Delete()

loRow.AcceptChanges()



'-- Move back to the original row

Me.SeekToPrimaryKey(loCurrentPk)

End If

End If







This has been a long hard non-billable day my friends.



Thanks,



CTBlankenship

Charles T. Blankenship
Senior Consultant
Novant Consulting, Inc.
704.975.7152
http://www.novantconsulting.com
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...





Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search