﻿<?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 » WinForms (How do I?)  » When I copy my "Search" BO used in the BrowseDialog to my "Real" BO used on the form</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Tue, 09 Jun 2026 06:33:58 GMT</lastBuildDate><ttl>20</ttl><item><title>When I copy my "Search" BO used in the BrowseDialog to my "Real" BO used on the form</title><link>http://forum.strataframe.net/FindPost20379.aspx</link><description>This code doesn't work becasue boProspectSearch.client_pk contains the PK of the first record even though I selected the 5th record in the grid. I know I should be able to do this because when I don't copy the data from the "Search" BO the form populated correctly with the selected record. So what do I need to do here?&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&lt;FONT color=#0000ff size=2&gt;private&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;void&lt;/FONT&gt;&lt;FONT size=2&gt; brwProspects_BrowseDialogClosed(MicroFour.StrataFrame.UI.Windows.Forms.&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;BrowseDialogClosedEventArgs&lt;/FONT&gt;&lt;FONT size=2&gt; e)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;// Copy the data from the prospect search business object&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;// to the clients business object&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;string&lt;/FONT&gt;&lt;FONT size=2&gt;[] lcFieldList = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;new&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;string&lt;/FONT&gt;&lt;FONT size=2&gt;[] { &lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;"client_pk"&lt;/FONT&gt;&lt;FONT size=2&gt;, &lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;"type_fk"&lt;/FONT&gt;&lt;FONT size=2&gt;, &lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;"tier_fk"&lt;/FONT&gt;&lt;FONT size=2&gt;, &lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;"company_nme"&lt;/FONT&gt;&lt;FONT size=2&gt;, &lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;"company_ein"&lt;/FONT&gt;&lt;FONT size=2&gt;, &lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;"stradd_nme"&lt;/FONT&gt;&lt;FONT size=2&gt;, &lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;"stradd_sfx"&lt;/FONT&gt;&lt;FONT size=2&gt;, &lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;"city_nme"&lt;/FONT&gt;&lt;FONT size=2&gt;, &lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;"state_nme"&lt;/FONT&gt;&lt;FONT size=2&gt;, &lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;"pcode_nme"&lt;/FONT&gt;&lt;FONT size=2&gt;, &lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;"active_flg"&lt;/FONT&gt;&lt;FONT size=2&gt;, &lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;"sales_fk"&lt;/FONT&gt;&lt;FONT size=2&gt;, &lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;"relat_fk"&lt;/FONT&gt;&lt;FONT size=2&gt;, &lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;"admin_fk"&lt;/FONT&gt;&lt;FONT size=2&gt;, &lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;"analy_fk"&lt;/FONT&gt;&lt;FONT size=2&gt;, &lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;"file_dir"&lt;/FONT&gt;&lt;FONT size=2&gt;, &lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;"csz_dsc"&lt;/FONT&gt;&lt;FONT size=2&gt;, &lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;"lastmod_nme"&lt;/FONT&gt;&lt;FONT size=2&gt;, &lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;"lastmod_dte"&lt;/FONT&gt;&lt;FONT size=2&gt; };&lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;Int32&lt;/FONT&gt;&lt;FONT size=2&gt; lnClient_pk;&lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;if&lt;/FONT&gt;&lt;FONT size=2&gt; (!boProspectSearch.IsEmpty)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;lnClient_pk = boProspectSearch.client_pk;&lt;/P&gt;&lt;P&gt;boClients.CopyDataFrom(boProspectSearch.CurrentDataTable.DefaultView.ToTable(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;true&lt;/FONT&gt;&lt;FONT size=2&gt;, lcFieldList), MicroFour.StrataFrame.Business.&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;BusinessCloneDataType&lt;/FONT&gt;&lt;FONT size=2&gt;.ClearAndFillFromCompleteTable);&lt;/P&gt;&lt;P&gt;boClients.NavigateToPrimaryKey(lnClient_pk);&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;/FONT&gt;&lt;P&gt;}</description><pubDate>Tue, 28 Oct 2008 11:23:37 GMT</pubDate><dc:creator>Marcia G Akins</dc:creator></item><item><title>RE: When I copy my "Search" BO used in the BrowseDialog to my "Real" BO used on the form</title><link>http://forum.strataframe.net/FindPost20394.aspx</link><description>LOL...glad you found what you needed :)</description><pubDate>Tue, 28 Oct 2008 11:23:37 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: When I copy my "Search" BO used in the BrowseDialog to my "Real" BO used on the form</title><link>http://forum.strataframe.net/FindPost20393.aspx</link><description>[quote][b]Trent L. Taylor (10/28/2008)[/b][hr]Yup, go into the BO Mapper, right-click the BO in question, the open the Advanced Options.&amp;nbsp; You can override the Primary Key.&amp;nbsp; This was actually implemented for this very purpose (when mapping to views).&amp;nbsp; It has other uses as well, but this is what spawned this feature.&lt;P&gt;[/quote]&lt;P&gt;Thanks a million, Trent! You are my hero!</description><pubDate>Tue, 28 Oct 2008 11:00:09 GMT</pubDate><dc:creator>Marcia G Akins</dc:creator></item><item><title>RE: When I copy my "Search" BO used in the BrowseDialog to my "Real" BO used on the form</title><link>http://forum.strataframe.net/FindPost20391.aspx</link><description>Yup, go into the BO Mapper, right-click the BO in question, the open the Advanced Options.&amp;nbsp; You can override the Primary Key.&amp;nbsp; This was actually implemented for this very purpose (when mapping to views).&amp;nbsp; It has other uses as well, but this is what spawned this feature.&lt;/P&gt;&lt;P&gt;&lt;IMG src="http://forum.strataframe.net/Uploads/Images/e6d4b5d7-a7e1-4b40-9da4-473e.png"&gt;</description><pubDate>Tue, 28 Oct 2008 10:54:04 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: When I copy my "Search" BO used in the BrowseDialog to my "Real" BO used on the form</title><link>http://forum.strataframe.net/FindPost20390.aspx</link><description>[quote][b]Trent L. Taylor (10/28/2008)[/b][hr]&lt;OL&gt;&lt;LI&gt;The dialog is shown and the results captured&lt;/LI&gt;&lt;LI&gt;The CurrentRowIndex is set within the BusinessObjectToPopulate (_BusinessObject)&lt;/LI&gt;&lt;LI&gt;The BrowseDialogClosed event is raised&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;So you can see that the CurrentRowIndex &lt;STRONG&gt;&lt;EM&gt;&lt;U&gt;should&lt;/U&gt;&lt;/EM&gt;&lt;/STRONG&gt; be set at this point, so as I mentioned, there could be something else going on here that I cannot see in your snippet.&amp;nbsp; A code sample always helps when trying to work through problems like this.&amp;nbsp; Let me know if this doesn't get you going in the right direction.[/quote]&lt;P&gt;&amp;nbsp;&lt;P&gt;OK - I think I know what is happening here. boProspectSearch is based on a ciew so no primary key is specified in the BP mapper. Therefore, loForm.SelectedPrimary key is Nothing :P.&lt;P&gt;Is there a way to tell the BO mapper that a field in the view is a primary key?</description><pubDate>Tue, 28 Oct 2008 10:37:09 GMT</pubDate><dc:creator>Marcia G Akins</dc:creator></item><item><title>RE: When I copy my "Search" BO used in the BrowseDialog to my "Real" BO used on the form</title><link>http://forum.strataframe.net/FindPost20388.aspx</link><description>You are welcome to produce a sample the replicates your behavior and post it here, but if you look at the ShowDialog method in the SF source code in the BrowseDialog class, you will see that the BrowseDialogClosed event isn't called until the index has been set, so there may be another factor here in your code.&amp;nbsp; Also, we use a technique similar to this (for other purposes) in our medical software, so I am confident that it will work, but there just may be something else in the mix here.&amp;nbsp; Here is the code that I an referring to:&lt;/P&gt;&lt;P&gt;&lt;IMG src="http://forum.strataframe.net/Uploads/Images/aa29426a-1d19-4e0f-b7b6-c4f6.png"&gt;&lt;/P&gt;&lt;P&gt;(I have also attacherd this image so you don't have to squint :D)&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;The dialog is shown and the results captured&lt;/LI&gt;&lt;LI&gt;The CurrentRowIndex is set within the BusinessObjectToPopulate (_BusinessObject)&lt;/LI&gt;&lt;LI&gt;The BrowseDialogClosed event is raised&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;So you can see that the CurrentRowIndex &lt;STRONG&gt;&lt;EM&gt;&lt;U&gt;should&lt;/U&gt;&lt;/EM&gt;&lt;/STRONG&gt; be set at this point, so as I mentioned, there could be something else going on here that I cannot see in your snippet.&amp;nbsp; A code sample always helps when trying to work through problems like this.&amp;nbsp; Let me know if this doesn't get you going in the right direction.</description><pubDate>Tue, 28 Oct 2008 10:14:41 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: When I copy my "Search" BO used in the BrowseDialog to my "Real" BO used on the form</title><link>http://forum.strataframe.net/FindPost20387.aspx</link><description>[quote][b]Trent L. Taylor (10/28/2008)[/b][hr]Well, I am a little confused here as to what you were expecting, but you are copying out of the CurrentDataTable after a search.&amp;nbsp; When you do this, the record pointer is irrelevant.&amp;nbsp; There is no record pointer in a data table, and when you call the CopyDatafrom method, the CurrentRowIndex is going to be reset.&amp;nbsp; So here are a couple of points:&lt;OL&gt;&lt;LI&gt;When you call a browse and it returns a record set, the CurrentRowIndex is "synced" up with the BusinessObjectToPopulate associated with the BrowseDialog (this is not part of the data table).&lt;/LI&gt;&lt;LI&gt;When you call a CopyDataFrom, you will need to save off and or reposition the record pointer yourself as the CopyDataFrom will move the CurrentRowIndex when clearing and refilling.&amp;nbsp; &lt;/LI&gt;&lt;LI&gt;In the BrowseDialogClosed event, the BusinessObjectToPopulate should already have the CurrentRowIndex set, so if you want to seek or reposition the BO after the copy, save off the selected PK and then scall a NavigateToPrimarykey or a SeekToPrimarykey after you call the CopyDataFrom.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;[/quote]&lt;/P&gt;&lt;P&gt;The problem is that when the BrowseDialog is closed, &lt;FONT size=2&gt;boProspectSearch.CurrentRowIndex = 0 no matter which row in the search results grid I have clicked on and &lt;FONT size=2&gt;boProspectSearch.client_pk is always the client_pk from the first record in the search results grid :angry:&lt;/P&gt;&lt;/FONT&gt;&lt;/FONT&gt;</description><pubDate>Tue, 28 Oct 2008 10:03:31 GMT</pubDate><dc:creator>Marcia G Akins</dc:creator></item><item><title>RE: When I copy my "Search" BO used in the BrowseDialog to my "Real" BO used on the form</title><link>http://forum.strataframe.net/FindPost20384.aspx</link><description>Well, I am a little confused here as to what you were expecting, but you are copying out of the CurrentDataTable after a search.&amp;nbsp; When you do this, the record pointer is irrelevant.&amp;nbsp; There is no record pointer in a data table, and when you call the CopyDatafrom method, the CurrentRowIndex is going to be reset.&amp;nbsp; So here are a couple of points:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;When you call a browse and it returns a record set, the CurrentRowIndex is "synced" up with the BusinessObjectToPopulate associated with the BrowseDialog (this is not part of the data table).&lt;/LI&gt;&lt;LI&gt;When you call a CopyDataFrom, you will need to save off and or reposition the record pointer yourself as the CopyDataFrom will move the CurrentRowIndex when clearing and refilling.&amp;nbsp; &lt;/LI&gt;&lt;LI&gt;In the BrowseDialogClosed event, the BusinessObjectToPopulate should already have the CurrentRowIndex set, so if you want to seek or reposition the BO after the copy, save off the selected PK and then scall a NavigateToPrimarykey or a SeekToPrimarykey after you call the CopyDataFrom.&lt;/LI&gt;&lt;/OL&gt;</description><pubDate>Tue, 28 Oct 2008 09:08:25 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: When I copy my "Search" BO used in the BrowseDialog to my "Real" BO used on the form</title><link>http://forum.strataframe.net/FindPost20382.aspx</link><description>[quote][b]Ivan George Borges (10/28/2008)[/b][hr]&lt;P&gt;Could it be that the record was a duplicate and didn't get copied?[/quote]&lt;P&gt;That is irrelevant. The primary key on all the duplicated records would be the same :)</description><pubDate>Tue, 28 Oct 2008 09:02:23 GMT</pubDate><dc:creator>Marcia G Akins</dc:creator></item><item><title>RE: When I copy my "Search" BO used in the BrowseDialog to my "Real" BO used on the form</title><link>http://forum.strataframe.net/FindPost20381.aspx</link><description>Hi Marcia.&lt;/P&gt;&lt;P&gt;Could it be that the record was a duplicate and didn't get copied?</description><pubDate>Tue, 28 Oct 2008 05:54:51 GMT</pubDate><dc:creator>Ivan George Borges</dc:creator></item></channel></rss>