When I click the search on the browsedialog I get an error. Artist is not recognized. When I walk through the debug code I see the browsedialog creates it's own fill method to return the results instead of using my fill method that contains the join. Is there a way to specify what fill method to use or a way to include my joined field?
thanks
Bill
If you are referring to the Sarch Fields, then you can handle the Searching event of the browse dialog to maniulate the raw WHERE clause of the query. Now redirecting to a join will be more difficult since it is another table. So you may want to create a view to query that has the join done on the server side which would then make this easier without the need to managing the Searching event.
If you are referring to the results, then you can define the column as PopulateThroughEvent and call a scalar method to populate the value or use a browse information panel.
So there are a lot of different options here, so depending on what you are trying to accomplish this should give you some ideas.
I understand that you want to show the name of the Artist in the Browse Dialog Result listview instead of the Artist_FK value. This is what you need to do:
''' <summary>''' This property will return the Artist Name''' </summary>''' <remarks></remarks><Browsable(False), _BusinessFieldDisplayInEditor(), _Description("ArtistName"), _DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _Public ReadOnly Property [ArtistName]() As System.String Get Dim loBusinessObject As New ArtistBO loBusinessObject.FillByPrimaryKey(Me.Artist_FK) If loBusinessObject.Count = 1 Then Return loBusinessObject.ArtistName Else Return String.Empty End If ' Release the Business Object loBusinessObject.Dispose() End GetEnd Property
<Browsable(
BusinessFieldDisplayInEditor(), _
Description(
DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
loBusinessObject.FillByPrimaryKey(
loBusinessObject.Dispose()
While setting the BrowseResultsDialog, by the time you are adding your foreign key column to be dislplayed, have a look at the Population Type, choose PopulatedThroughEvent.
Then, go to your BrowseDialog Events and add an event handler for the RowPopulating.
In it, you can deal with sending the appropriate content for the BrowseDialog results column, something like this:
Private Sub MyBrowseDialog_RowPopulating(ByVal e As MicroFour.StrataFrame.UI.Windows.Forms.RowPopulatingEventArgs) Handles MyBrowseDialog.RowPopulating '-- you can use whatever methods suit you better to get the values you need '-- you could create a method on your BO with a ExecuteScalar method to bring back only the information needed
'-- establish locals Dim loBO As New MyBO loBO.FillByPrimaryKey(MyOtherBO.MyForeignKey)
'-- set the contents With CType(e.BusinessObject, MyBO) e.Values(0).DisplayValue = loBO.MyField End With End Sub
Hope it helps.
PopulateThroughEvent method sounds like the right one for me. I want to see the artist name in the listview not an info panel. I will just need to make a call to the retrieve the artist name based on the artist_FK on the current row right?
Thanks
I ended up using Edhy's sample to resolve my issue. Works great
Thank you
Glad it work for you, but keep in mind that this method will do a trip to the database to get the Artist Name value to be shown in the listview, this is acceptable in most cases if your search in the BD (Browser Dialog) will not return many records, but if that is the case, there are many alternate methods like Trent and Ivan said, in which you can use either use an Scalar method to just return the Artist Name field or to create a temporary BO in the BD with all the Artist Name and use the BO.SeektoPrimaryKey(Artist_FK) to get its name in the RowPopulation event.