| | | 
StrataFrame Novice
       
Group: Forum Members Last Login: 06/19/2008 11:16:33 AM Posts: 73, Visits: 12,471 |
| 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 |
| | | | 
StrataFrame Developer

Group: StrataFrame Developers Last Login: Yesterday @ 4:58:13 AM Posts: 4,379, Visits: 4,421 |
| | You are not going to want to delete through the CurrentRow...this may potentitally wreak havoc on a number of different levels. First of all you should really use the following command: MyBO.DeleteCurrentRow(True) The above command will only mark the row as deleted (the True) and not go back to the server, obviously False will go back to the server. Second, if you don't want to commit the changes, then you can call the following command: MyBO.CurrentDataTable.AcceptChanges() This wasy you are staying within the logic of the BO. Even if you want to call the delete on the data table directly would be safer than passing of the row reference and the smoking it: MyBO.CurrentDataTable.Rows(MyBO.CurrentRowIndex).Delete() Any of these are going to be much safer. I recommend the first option as it remains within the BO logic. |
| | | | 
StrataFrame Novice
       
Group: Forum Members Last Login: 06/19/2008 11:16:33 AM Posts: 73, Visits: 12,471 |
| Hey Buddy:
I'm calling this method ...
Private Function DeleteByPrimaryKey(ByVal PKValue As PrimaryKeyValue) As Integer
which has this code in it
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
Notice that the value in Me._CurrentRowIndex is not tested for 0 before a decrement occurs ... in my case this causes the the _CurrentRowIndex to contain a -1 which throws the aforementioned error. Sorry I mislead you by not posting the whole piece of the pie.
Thanks,
CT
|
| | | | 
StrataFrame Developer

Group: StrataFrame Developers Last Login: Yesterday @ 4:58:13 AM Posts: 4,379, Visits: 4,421 |
| | Oh....I will look into this....you will get the results you are looking for calling the following method: MyBO.DeleteCurrentRow(False) But be sure to navigate to the proper row before smoking it: If MyBO.SeekToPrimaryKey(MyPrimaryKey) Then MyBO.DeleteCurrentRow(False) End If |
| | | | 
StrataFrame Developer

Group: StrataFrame Developers Last Login: Yesterday @ 4:58:13 AM Posts: 4,379, Visits: 4,421 |
| | After looking at the code and running a test, the code in the DeleteByPrimaryKey is actually correct. The Navigate accounts for a negative row index. There is something else going on in your environment that could be causing the problem. Just so you know, you don't even need any records in the BO in order to delete a record from the server. If you are wanting to delete a record from the server that is already in your BO, the use the DeleteCurrentRow method...you will have fewer issues with other bindings and delegates that may be in the formula. |
| | | | 
StrataFrame Novice
       
Group: Forum Members Last Login: 06/19/2008 11:16:33 AM Posts: 73, Visits: 12,471 |
| | Ah ... those two pieces of information are nice to know. Thanks for your time and attention my friend. CT |
| | | | 
StrataFrame Developer

Group: StrataFrame Developers Last Login: Yesterday @ 4:58:13 AM Posts: 4,379, Visits: 4,421 |
| No problem |
| |
|
|