﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>StrataFrame Forum / StrataFrame Application Framework / WebForms (How do I?)  / Deleting the first item in a List / Latest Posts</title><generator>InstantForum.NET v4.1.4</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>forum@strataframe.net</webMaster><lastBuildDate>Thu, 20 Nov 2008 02:11:55 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Deleting the first item in a List</title><link>http://forum.strataframe.net/Topic5104-8-1.aspx</link><description>No problem :)</description><pubDate>Fri, 08 Dec 2006 09:00:50 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: Deleting the first item in a List</title><link>http://forum.strataframe.net/Topic5104-8-1.aspx</link><description>Ah ... those two pieces of information are nice to know.  Thanks for your time and attention my friend.&lt;/P&gt;&lt;P&gt;CT</description><pubDate>Fri, 08 Dec 2006 08:26:25 GMT</pubDate><dc:creator>Charles Thomas Blankenship</dc:creator></item><item><title>RE: Deleting the first item in a List</title><link>http://forum.strataframe.net/Topic5104-8-1.aspx</link><description>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.</description><pubDate>Thu, 07 Dec 2006 21:50:47 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: Deleting the first item in a List</title><link>http://forum.strataframe.net/Topic5104-8-1.aspx</link><description>Oh....I will look into this....you will get the results you are looking for calling the following method:&lt;P&gt;[codesnippet]MyBO.DeleteCurrentRow(False)[/codesnippet]&lt;P&gt;But be sure to navigate to the proper row before smoking it:&lt;P&gt;[codesnippet]If MyBO.SeekToPrimaryKey(MyPrimaryKey) Then &lt;BR&gt;    MyBO.DeleteCurrentRow(False)&lt;BR&gt;End If[/codesnippet]</description><pubDate>Thu, 07 Dec 2006 21:44:46 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: Deleting the first item in a List</title><link>http://forum.strataframe.net/Topic5104-8-1.aspx</link><description>Hey Buddy:&lt;br&gt;&lt;br&gt;I'm calling this method ...  &lt;br&gt;&lt;br&gt;Private Function DeleteByPrimaryKey(ByVal PKValue As PrimaryKeyValue) As Integer&lt;br&gt;&lt;br&gt;which has this code in it &lt;br&gt;&lt;PRE&gt;&lt;br&gt;If loCurrentPk.Equals(PKValue) Then&lt;br&gt;                    '-- Remove the current row and navigate to the next row&lt;br&gt;                    loRow = Me.CurrentRow&lt;br&gt;                    loRow.Delete()&lt;br&gt;                    loRow.AcceptChanges()&lt;br&gt;&lt;br&gt;                    '-- Decrement the index and navigate&lt;br&gt;                    Me._CurrentRowIndex -= 1&lt;br&gt;                    Me.Navigate(BusinessNavigationDirection.Next)&lt;br&gt;                Else&lt;br&gt;&lt;/PRE&gt;&lt;br&gt;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.&lt;br&gt;&lt;br&gt;Thanks,&lt;br&gt;&lt;br&gt;CT&lt;br&gt;&lt;br&gt;</description><pubDate>Thu, 07 Dec 2006 21:39:51 GMT</pubDate><dc:creator>Charles Thomas Blankenship</dc:creator></item><item><title>RE: Deleting the first item in a List</title><link>http://forum.strataframe.net/Topic5104-8-1.aspx</link><description>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:&lt;P&gt;[codesnippet]MyBO.DeleteCurrentRow(True)[/codesnippet]&lt;/P&gt;&lt;P&gt;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:&lt;/P&gt;&lt;P&gt;[codesnippet]MyBO.CurrentDataTable.AcceptChanges()[/codesnippet]&lt;/P&gt;&lt;P&gt;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:&lt;/P&gt;&lt;P&gt;[codesnippet]MyBO.CurrentDataTable.Rows(MyBO.CurrentRowIndex).Delete()[/codesnippet]&lt;/P&gt;&lt;P&gt;Any of these are going to be much safer.  I recommend the first option as it remains within the BO logic.</description><pubDate>Thu, 07 Dec 2006 19:27:08 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>Deleting the first item in a List</title><link>http://forum.strataframe.net/Topic5104-8-1.aspx</link><description>Everytime I delete the first item in my list I get the following error:&lt;br&gt;&lt;br&gt;&lt;br&gt;The CurrentRow could not be evaluated because the CurrentRowIndex is out of range.  Business object record count: 7.  CurrentRowIndex: -1. &lt;br&gt;&lt;br&gt;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?&lt;br&gt;&lt;br&gt;&lt;PRE&gt;&lt;br&gt;                If loCurrentPk.Equals(PKValue) Then&lt;br&gt;                    '-- Remove the current row and navigate to the next row&lt;br&gt;                    loRow = Me.CurrentRow&lt;br&gt;                    loRow.Delete()&lt;br&gt;                    loRow.AcceptChanges()&lt;br&gt;&lt;br&gt;                    '-- Decrement the index and navigate&lt;br&gt;                    Me._CurrentRowIndex -= 1&lt;br&gt;                    Me.Navigate(BusinessNavigationDirection.Next)&lt;br&gt;                Else&lt;br&gt;                    '-- Find the row to delete&lt;br&gt;                    If Me.SeekToPrimaryKey(PKValue) Then&lt;br&gt;                        '-- Remove the row&lt;br&gt;                        loRow = Me.CurrentRow&lt;br&gt;                        loRow.Delete()&lt;br&gt;                        loRow.AcceptChanges()&lt;br&gt;&lt;br&gt;                        '-- Move back to the original row&lt;br&gt;                        Me.SeekToPrimaryKey(loCurrentPk)&lt;br&gt;                    End If&lt;br&gt;                End If&lt;br&gt;&lt;br&gt;&lt;/PRE&gt;&lt;br&gt;&lt;br&gt;This has been a long hard non-billable day my friends.&lt;br&gt;&lt;br&gt;Thanks,&lt;br&gt;&lt;br&gt;CTBlankenship</description><pubDate>Thu, 07 Dec 2006 16:33:00 GMT</pubDate><dc:creator>Charles Thomas Blankenship</dc:creator></item></channel></rss>