﻿<?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 - V1 » Business Objects and Data Access (How do I?)  » .NewRow() doesn't move the newly added row</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Wed, 24 Jun 2026 11:11:55 GMT</lastBuildDate><ttl>20</ttl><item><title>.NewRow() doesn't move the newly added row</title><link>http://forum.strataframe.net/FindPost21921.aspx</link><description>Hi,&lt;br&gt;
I am seeing this behavior in StrataFrame:&lt;br&gt;
When calling .NewRow() inside one of the BO methods, the current row position doesn't change to the new row as per documentation.&lt;br&gt;
&lt;br&gt;
[codesnippet]&lt;br&gt;
this.NewRow();&lt;br&gt;
Debug.WriteLine(this["IndexId"].ToString()); //Expect to see -1, but it's not the case&lt;br&gt;
Debug.WriteLine(this.CurrentRow.RowState.ToString());  //Expect to see 'Added', but get 'Unchanged' instead&lt;br&gt;
[/codesnippet]&lt;br&gt;
&lt;br&gt;
Either I am doing something wrong or it's a bug in SF ;)</description><pubDate>Fri, 20 Feb 2009 10:00:45 GMT</pubDate><dc:creator>Leonard P.</dc:creator></item><item><title>RE: .NewRow() doesn't move the newly added row</title><link>http://forum.strataframe.net/FindPost22043.aspx</link><description>[quote] Most likely there is something in your code that is preventing the record from moving or moving it back.  Please provide a sample so that we can look.[/quote]&lt;br&gt;
&lt;br&gt;
Hi Trent, &lt;br&gt;
You are absolutely right; there's probably something in my code. I tried to isolate this problem in a smaller test project. So, I created a new project with test BO, BusinessBundingSource, DataGridView, and an Add Button, but I wasn't able to reproduce it.&lt;br&gt;
While in the original project where it's happening, I have some additional code in SetDefaultValues event of a base class. Probably something in there that offsetting the record position.&lt;br&gt;
I am going to do more research on my end. Hopefully I can crack this thing on my own here, if not we will be chatting again :)&lt;br&gt;
&lt;br&gt;
Thanks for your help.&lt;br&gt;
&lt;br&gt;</description><pubDate>Fri, 20 Feb 2009 10:00:45 GMT</pubDate><dc:creator>Leonard P.</dc:creator></item><item><title>RE: .NewRow() doesn't move the newly added row</title><link>http://forum.strataframe.net/FindPost22042.aspx</link><description>You will have to provide a sample then as I know that this works.&amp;nbsp; Most likely there is something in your code that is preventing the record from moving or moving it back.&amp;nbsp; Please provide a sample so that we can look.</description><pubDate>Fri, 20 Feb 2009 08:51:03 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: .NewRow() doesn't move the newly added row</title><link>http://forum.strataframe.net/FindPost22038.aspx</link><description>Hi Trent,&lt;br&gt;
I've installed the latest beta version from the link you provided, but it didn't resolve this issue. It's still happening. :(&lt;br&gt;
Can you advise if there's anything I need to do?&lt;br&gt;
&lt;br&gt;
Thanks</description><pubDate>Thu, 19 Feb 2009 21:01:59 GMT</pubDate><dc:creator>Leonard P.</dc:creator></item><item><title>RE: .NewRow() doesn't move the newly added row</title><link>http://forum.strataframe.net/FindPost21944.aspx</link><description>If you are using a BBS and under certain other conditions, there was a bug where the index would not move.&amp;nbsp; This was ono a different thread wth Anrdia and another with Greg and was fixed a while back.&amp;nbsp; If you load the most recent beta this has already been addressed.&amp;nbsp; Otherwise, you will have to wait until the final build before I can give you an assembly to resolve this issue.&lt;/P&gt;&lt;P&gt;Go here: &lt;A href="http://forum.strataframe.net/FindPost21409.aspx"&gt;http://forum.strataframe.net/FindPost21409.aspx&lt;/A&gt;&amp;nbsp;and look at #19.</description><pubDate>Thu, 12 Feb 2009 13:56:00 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: .NewRow() doesn't move the newly added row</title><link>http://forum.strataframe.net/FindPost21942.aspx</link><description>As you can see the code is very much modularize, .NewRow() is one line in 2 lines "ImportNewSpecRow" function . But here's all the relevant code context:&lt;br&gt;
&lt;br&gt;
[codesnippet]&lt;br&gt;
protected virtual void ImportSpecsDataTable(DataTable specsTable, ImportSpecsOption options)&lt;br&gt;
        {&lt;br&gt;
            foreach (DataRow dr in specsTable.Rows)&lt;br&gt;
            {&lt;br&gt;
&lt;br&gt;
                if (options == ImportSpecsOption.DeleteAndInsert)&lt;br&gt;
                    ImportNewSpecRow(dr); // will call .NewRow&lt;br&gt;
                else&lt;br&gt;
                    MergeSpecRow(dr);&lt;br&gt;
            }&lt;br&gt;
        }&lt;br&gt;
&lt;br&gt;
   protected virtual void MergeSpecRow(DataRow dr)&lt;br&gt;
        {&lt;br&gt;
            int indexId = -1;&lt;br&gt;
            string pkFieldName = this.PrimaryKeyField;&lt;br&gt;
            if (dr[pkFieldName] != null &amp;&amp; !dr[pkFieldName].ToString().Equals(string.Empty))&lt;br&gt;
                indexId = int.Parse(dr[pkFieldName].ToString());&lt;br&gt;
&lt;br&gt;
            if (IsIndexIdinBO(indexId))&lt;br&gt;
                CopyDataFromDRtoCurrentRow(dr);                &lt;br&gt;
            else&lt;br&gt;
                ImportNewSpecRow(dr); // will call .NewRow&lt;br&gt;
        }&lt;br&gt;
&lt;br&gt;
  protected virtual void ImportNewSpecRow(DataRow dr)&lt;br&gt;
        {&lt;br&gt;
            this.NewRow(); //Problem is here. Debug.Write(this.CurrentRow.RowState.ToString()) outputs 'Unchanged', but 'Added' is expected&lt;br&gt;
             NaviagateToNewRow(); //This is the work around for .NewRow() not navigating to  the NewRow&lt;br&gt;
&lt;br&gt;
            CopyDataFromDRtoCurrentRow(dr); //this function needs this.CurrentRow to be new Row&lt;br&gt;
        }&lt;br&gt;
&lt;br&gt;
        protected void NaviagateToNewRow()&lt;br&gt;
        {&lt;br&gt;
            if (this.CurrentRow.RowState == DataRowState.Added)&lt;br&gt;
                return;&lt;br&gt;
&lt;br&gt;
            if (this.PrimaryKeyFields.Length &gt; 1)&lt;br&gt;
                throw new ApplicationException("Failed to Naviage to the new row");&lt;br&gt;
&lt;br&gt;
            this.CurrentView.Sort = this.PrimaryKeyField + " asc";&lt;br&gt;
            int minId = int.Parse(this.CurrentView[0][this.PrimaryKeyField].ToString());            &lt;br&gt;
            this.CurrentView.Sort = string.Empty;&lt;br&gt;
            this.NavigateToPrimaryKey(minId);&lt;br&gt;
        }&lt;br&gt;
[/codesnippet]&lt;br&gt;
&lt;br&gt;
I should also mention that the callstack is ImportSpecsDataTable -&gt; MergeSpecRow -&gt; ImportNewSpecRow -&gt; this.NewRow().&lt;br&gt;
Hope it helps.</description><pubDate>Thu, 12 Feb 2009 13:38:47 GMT</pubDate><dc:creator>Leonard P.</dc:creator></item><item><title>RE: .NewRow() doesn't move the newly added row</title><link>http://forum.strataframe.net/FindPost21941.aspx</link><description>[quote][b]Leonard P. (02/12/2009)[/b][hr]Thanks Dustin,Yes, it's very strange. It works fine in other BOs wherever I use .NewRow(). It's only in this particular BO where I am having this problem. [/quote]&lt;P&gt;Leonard, could you post the whole code where the .NewRow() is used?</description><pubDate>Thu, 12 Feb 2009 13:14:14 GMT</pubDate><dc:creator>Edhy Rijo</dc:creator></item><item><title>RE: .NewRow() doesn't move the newly added row</title><link>http://forum.strataframe.net/FindPost21938.aspx</link><description>Thanks Dustin,&lt;br&gt;
&lt;br&gt;
Yes, it's very strange. It works fine in other BOs wherever I use .NewRow(). It's only in this particular BO where I am having this problem. And there's nothing special about this particular object. Other than .NewRow() is called inside BO's method and not outside SF form for example.&lt;br&gt;
&lt;br&gt;
I do see new row being added in the underlying DataTable. And I can navigate to it manually, in fact this is the work out I implemented for now until I can find what's causing this problem.&lt;br&gt;
&lt;br&gt;
Thanks</description><pubDate>Thu, 12 Feb 2009 13:02:25 GMT</pubDate><dc:creator>Leonard P.</dc:creator></item><item><title>RE: .NewRow() doesn't move the newly added row</title><link>http://forum.strataframe.net/FindPost21926.aspx</link><description>Howdy :)&lt;/P&gt;&lt;P&gt;I just double checked this and it is working as designed on my end. Have you looked at the CurrentDataTable to ensure that it is adding a new row, and the problem is that the pointer isn't moving? Also, have you tried making a little test project to simplify things and making sure that this happens there too? There is probably something set on the business object that is keeping it from creating that new row, but off the top of my head I'm not sure what that might be. Let's start by checking those two things and we'll get to the bottom of it :).</description><pubDate>Thu, 12 Feb 2009 08:45:58 GMT</pubDate><dc:creator>Dustin Taylor</dc:creator></item></channel></rss>