| | | StrataFrame Beginner
       
Group: StrataFrame Users Last Login: 09/13/2008 2:30:51 AM Posts: 36, Visits: 43 |
| | I'm trying to set up a Child Form.I 've set up the Parent and Child Business Objects. I've dropped both on a SF Maintenece form. I've set up a PageFrame , one of the tabs is the Child Form. I have dropped a BusinessBindingSource on the form and set its datasource as the child bus object. I have also set the ParentBusinessObject of the childbuiness object on the form.I am displaying all fields in the child. As I naviagte through the patrent, I would expect to see the childdren in the grid, as the parent is navigated to...but nothing is appearing in the child grid. Should this behaviour be automatic, or is there someting I need to do to 'GET'the children into the grid ? |
| | | | StrataFrame Novice
       
Group: StrataFrame Users Last Login: Today @ 11:22:37 AM Posts: 86, Visits: 702 |
| Hello Gerard
It is always useful going through the SF samples provided, the way it works for me is adding this to the navigated event of the primary BO
Private Sub Orders_Navigated(ByVal e As MicroFour.StrataFrame.Business.NavigatedEventArgs) Handles Orders.Navigated
If Orders.Count > 0 Then
Me.OrderItems.FillByParentPrimaryKey(Me.Orders.pk)
End If
End Sub
I hope this helps 
MS Windows XP SP3
AMD Athlon 64 Processor 3000+
3,2 GB RAM, Radeon X1600/x1650 Series |
| | | | StrataFrame Beginner
       
Group: StrataFrame Users Last Login: 09/13/2008 2:30:51 AM Posts: 36, Visits: 43 |
| | Hi Guillermo. I have inserted code: ChildBO.FillByPrimaryKey(ParentBO.PrimaryKeyField); in the Navigating event of the Parent BO but still nothing happenning on the child grid. My Parent Primary Key is not the key into the child..another field on the Parent Table acts as the key....dont know if this matters ? |
| | | | Advanced StrataFrame User
       
Group: StrataFrame Users Last Login: Today @ 5:16:24 PM Posts: 608, Visits: 2,496 |
| Gerard O Carroll (06/09/2008)
My Parent Primary Key is not the key into the child..another fieldon the Parent Table acts as the key....dont knowif this matters ?
Hi Gerard,
Yes it does matter, since the FillByPrimaryKey will identify the defined PrimaryKey field(s) in the parent. I believe you will have to create your own FillBy method in the child BO and use that instead.
|
| | | | 
StrataFrame Developer

Group: StrataFrame Developers Last Login: Yesterday @ 8:00:28 PM Posts: 4,534, Visits: 4,522 |
| | Edhy is correct. You will just need to create your own Fill method to load the records that you need based on the specified parent record. So just create a Fill method on the child BO and call that Fill method on the Navigated event. |
| | | | StrataFrame Beginner
       
Group: StrataFrame Users Last Login: 09/13/2008 2:30:51 AM Posts: 36, Visits: 43 |
| | Some sample code would be appreciated as I am unclear as to what a '"Fill" method is or what code to put in it To recap, My Parent Business Object has a Pk feld(Primary Key) as well as a ParentStkref Field which links to the Child Table (The linked field in the Child table is say ChildStkref) |
| | | | 
StrataFrame Developer

Group: StrataFrame Developers Last Login: Yesterday @ 8:00:28 PM Posts: 4,534, Visits: 4,522 |
| Below would be an example of a Fill methodPublic Sub FillMyBO(ByVal ParentValue As Integer) '-- Establish Locals Dim cmd As New SqlCommand("SELECT * FROM MyTable WHERE myParentField = @parentFieldValue") '-- Create the parms cmd.Parameters.AddWithValue("@parentFieldValue", ParentValue).SqlDbType = SqlDbType.Int '-- Fill the BO Me.FillDataTable(cmd) End Sub |
| | | | Advanced StrataFrame User
       
Group: StrataFrame Users Last Login: Today @ 5:16:24 PM Posts: 608, Visits: 2,496 |
| Trent L. Taylor (06/09/2008) Edhy is correct. You will just need to create your own Fill method to load the records that you need based on the specified parent record. So just create a Fill method on the child BO and call that Fill method on the Navigated event.
Hi Gerard,
Here is a code I use in a child BO:
Public Sub FillByPolicy(ByVal FK_Policy As Integer)
Using cmd As New SqlCommand()
cmd.CommandText = String.Format("SELECT * FROM {0} WHERE FK_Policy={1} ", Me.TableName, FK_Policy)
Me.FillDataTable(cmd)
End Using
End Sub
After creating this method, compile your BO library or your solution then use that method instead of the FillByParentPrimaryKey().
|
| | | | StrataFrame Beginner
       
Group: StrataFrame Users Last Login: 09/13/2008 2:30:51 AM Posts: 36, Visits: 43 |
| | I have set up a Separate Fill method but am getting an error. In trying to find out the reason for the error, I have put a Messagebox in the Navigating event of the parent business object as MessageBox.Show(ParentBO.Stref) . I get a --> Current Row could not be evaluated because the current row index is out of range..record count is the last record in the business object...the error is coming from the Get for this field ..loValue=This.CurrentRow["stref"] in the framewrok code. If I take out the MessageBox, I can scroll up and down the parent business object without any errors. My Messagebox is just trying to display a field on the table ....but it seems to be going to EOF for some rason... I dont have any orhte code in there except this. |
| | |
|