.NewRow() doesn't move the newly added row


Author
Message
Leonard P.
Leonard P.
StrataFrame Novice (83 reputation)StrataFrame Novice (83 reputation)StrataFrame Novice (83 reputation)StrataFrame Novice (83 reputation)StrataFrame Novice (83 reputation)StrataFrame Novice (83 reputation)StrataFrame Novice (83 reputation)StrataFrame Novice (83 reputation)StrataFrame Novice (83 reputation)
Group: Awaiting Activation
Posts: 65, Visits: 306
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.




Hi Trent,

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.

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.

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 Smile



Thanks for your help.



Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
You will have to provide a sample then as I know that this works.  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.
Leonard P.
Leonard P.
StrataFrame Novice (83 reputation)StrataFrame Novice (83 reputation)StrataFrame Novice (83 reputation)StrataFrame Novice (83 reputation)StrataFrame Novice (83 reputation)StrataFrame Novice (83 reputation)StrataFrame Novice (83 reputation)StrataFrame Novice (83 reputation)StrataFrame Novice (83 reputation)
Group: Awaiting Activation
Posts: 65, Visits: 306
Hi Trent,

I've installed the latest beta version from the link you provided, but it didn't resolve this issue. It's still happening. Sad

Can you advise if there's anything I need to do?



Thanks
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
If you are using a BBS and under certain other conditions, there was a bug where the index would not move.  This was ono a different thread wth Anrdia and another with Greg and was fixed a while back.  If you load the most recent beta this has already been addressed.  Otherwise, you will have to wait until the final build before I can give you an assembly to resolve this issue.

Go here: http://forum.strataframe.net/FindPost21409.aspx and look at #19.

Leonard P.
Leonard P.
StrataFrame Novice (83 reputation)StrataFrame Novice (83 reputation)StrataFrame Novice (83 reputation)StrataFrame Novice (83 reputation)StrataFrame Novice (83 reputation)StrataFrame Novice (83 reputation)StrataFrame Novice (83 reputation)StrataFrame Novice (83 reputation)StrataFrame Novice (83 reputation)
Group: Awaiting Activation
Posts: 65, Visits: 306
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:





protected virtual void ImportSpecsDataTable(DataTable specsTable, ImportSpecsOption options)

{

foreach (DataRow dr in specsTable.Rows)

{



if (options == ImportSpecsOption.DeleteAndInsert)

ImportNewSpecRow(dr); // will call .NewRow

else

MergeSpecRow(dr);

}

}



protected virtual void MergeSpecRow(DataRow dr)

{

int indexId = -1;

string pkFieldName = this.PrimaryKeyField;

if (dr[pkFieldName] != null && !dr[pkFieldName].ToString().Equals(string.Empty))

indexId = int.Parse(dr[pkFieldName].ToString());



if (IsIndexIdinBO(indexId))

CopyDataFromDRtoCurrentRow(dr);

else

ImportNewSpecRow(dr); // will call .NewRow

}



protected virtual void ImportNewSpecRow(DataRow dr)

{

this.NewRow(); //Problem is here. Debug.Write(this.CurrentRow.RowState.ToString()) outputs 'Unchanged', but 'Added' is expected

NaviagateToNewRow(); //This is the work around for .NewRow() not navigating to the NewRow



CopyDataFromDRtoCurrentRow(dr); //this function needs this.CurrentRow to be new Row

}



protected void NaviagateToNewRow()

{

if (this.CurrentRow.RowState == DataRowState.Added)

return;



if (this.PrimaryKeyFields.Length > 1)

throw new ApplicationException("Failed to Naviage to the new row");



this.CurrentView.Sort = this.PrimaryKeyField + " asc";

int minId = int.Parse(this.CurrentView[0][this.PrimaryKeyField].ToString());

this.CurrentView.Sort = string.Empty;

this.NavigateToPrimaryKey(minId);

}





I should also mention that the callstack is ImportSpecsDataTable -> MergeSpecRow -> ImportNewSpecRow -> this.NewRow().

Hope it helps.
Edhy Rijo
E
StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Leonard P. (02/12/2009)
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.

Leonard, could you post the whole code where the .NewRow() is used?

Edhy Rijo

Leonard P.
Leonard P.
StrataFrame Novice (83 reputation)StrataFrame Novice (83 reputation)StrataFrame Novice (83 reputation)StrataFrame Novice (83 reputation)StrataFrame Novice (83 reputation)StrataFrame Novice (83 reputation)StrataFrame Novice (83 reputation)StrataFrame Novice (83 reputation)StrataFrame Novice (83 reputation)
Group: Awaiting Activation
Posts: 65, Visits: 306
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. 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.



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.



Thanks
Dustin Taylor
Dustin Taylor
StrataFrame Team Member (660 reputation)
Group: StrataFrame Users
Posts: 364, Visits: 771
Howdy Smile

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 Smile.

Leonard P.
Leonard P.
StrataFrame Novice (83 reputation)StrataFrame Novice (83 reputation)StrataFrame Novice (83 reputation)StrataFrame Novice (83 reputation)StrataFrame Novice (83 reputation)StrataFrame Novice (83 reputation)StrataFrame Novice (83 reputation)StrataFrame Novice (83 reputation)StrataFrame Novice (83 reputation)
Group: Awaiting Activation
Posts: 65, Visits: 306
Hi,

I am seeing this behavior in StrataFrame:

When calling .NewRow() inside one of the BO methods, the current row position doesn't change to the new row as per documentation.





this.NewRow();

Debug.WriteLine(this["IndexId"].ToString()); //Expect to see -1, but it's not the case

Debug.WriteLine(this.CurrentRow.RowState.ToString()); //Expect to see 'Added', but get 'Unchanged' instead





Either I am doing something wrong or it's a bug in SF Wink
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