Using SeekByPrimaryKey


Author
Message
Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
I am attempting to edit/save (aka update) selected BO's represented on a grid. Here is the code that I am using to accomplish this seemingly easy task:





waitWindow1.Message = "Updating the following parts . . . \r";

waitWindow1.ShowWaitWindow();

int[] mRows = gridView1.GetSelectedRows();

for (int i = 0; i < gridView1.SelectedRowsCount; i++)

{

int mPartIndex = (int)gridView1.GetRowCellValue(mRows[i], "partindex");

if (partsBO1.SeekToPrimaryKey(mPartIndex))

{

waitWindow1.Message += partsBO1.partnum + "\r";

partsBO1.Edit();

if (chkProdAppend.Checked) { partsBO1.prodnotes += txtNewNote.Text; }

if (chkProdReplace.Checked) { partsBO1.prodnotes = txtNewNote.Text; }

if (chkShipAppend.Checked) { partsBO1.shipnotes += txtNewNote.Text; }

if (chkShipReplace.Checked) { partsBO1.shipnotes = txtNewNote.Text; }

partsBO1.Save();

}

}

waitWindow1.HideWaitWindow();





The result of this code is that only the first and last record are updated. All other selected parts in between are ignored. Each part number shows up in the WaitWindow as I cycle through the selected records; however, only the first and last records are actually persisted to the database.



Blink



Any ideas?



Thanks,

Bill

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
Hi Bill,



Not sure if this is your case, but it looks like the BO.CurrentRow.RowState is not being set to Modified when you edit it.



Until you find what may be causing this, you could use the following code to force the RowState to the desired state so all records can be saved, the code is in VB (sorry BigGrin)



If BO.CurrentRow.RowState = Data.DataRowState.Unchanged Then

BO.CurrentRow.SetModified()

End If



Edhy Rijo

Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
Edhy...thanks. Here is what I introduced to my code just before the Save() call:



if (partsBO1.CurrentRow.RowState == DataRowState.Unchanged) { partsBO1.CurrentRow.SetModified(); }



It had no effect. After a bit more investigation, I am discovering that the item that has the focus is getting updated at the server...so it is not the first and last as I originally thought. This is still strange since I am actually hitting each select BO in my code and calling the Edit() and Save() methods on the record. I am still missing something. It is like some kind of commit is not happening while using the seek except for the focused BO.
Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
Now...here's some more data for us to ponder...



The screenshot (attached) shows the three items that I selected to replace the shipping note with the word "cool". You cannot tell, but I purposely selected the first record, too, but then deselected it and left the focus on that row. When I click the "Apply Selected" button, the three items I have selected are indeed the only three that are cycled in my code (I watched them in the debugger); however, the strange thing is that the first, unselected item was updated and the second item (the first selected item) was updated. The last two items were untouched.



I thought a fresh start this morning would help things, but it has only gotten worse. Crying



Perhaps half a cup of coffee is not enough. Need more coffee.



Bill
Attachments
seektoprimarykeyexample.JPG (129 views, 47.00 KB)
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
OK, there can be a number of things going on here. First, you are using a grid and trying to seek within grid events...thins can get hairy because the grid ultimately wants control. the ONLY way this can happen...seriously...the ONLY way is if the BO is navigated to these records. So one of the following this is going on:



1. The grid is navigating to these records when when getting the values.

2. You have a sort or filter applied (or the grid is applying one)

3. The planets are beginning to align for a total eclipse! BigGrin



Possible Resolutions or Debugging Ideas:



1. Remove any filters and/or sorts

2. Put a break point in the navigating event of the BO and then look at the call stack to see what is navigating the BO.

3. USE A LISTVIEW BigGrin In this particular screen shot, I see no reason for the grid. Grids are fat and have a ton of overhead. When just displaying row elements that are maintained OUTSIDE of the grid, you are asking for trouble. Just my 2 cents! Smile
Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
3. The planets are beginning to align for a total eclipse!




That's it!!! BigGrin



I'll start by replacing the grid with a list. We'll see what happens after that. Thanks (as always) for the tip!



Bill
Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
Ok. The ListView displays the data from a query within its own assigned business object. I can even copy the data from the form's business object after the current data table is refilled. That work nicely to pick up the browse dialog's search results. But I need the list to directly reflect the business object on the form and to navigate the business object when the pointer changes on the ListView. I do not see how to get these two items to work in tandem. Also, even though I have set the ListView to multi-select, only one row at a time can be selected.
Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
AutoNavigateToSelectedRecord



Setting this to true did the trick of synchronizing the list to the BO.



Now, I just need to get the multi-select feature to work.
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 set the MultiSelect property to true in code. It is overwritten by the default class (to resolve other issues fought in the past). So after the OnLoad, set this and you should be good.
Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
Yepper...that was the ticket.



So far, we have replaced that fat grid with a thin list. The list is playing nicely with the BO on the form and I can multi-select the items on the list.



Now, when I rifle through the selected items and try to seek to that record...the edit/save routine does not work. The wait window displays the selected parts (see code above), but does not actually persist my change.



Still at square one. But, I did learn some things.
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