newbie master details design time binding issues

Posts   
 
    
mhollers
User
Posts: 2
Joined: 19-May-2009
# Posted on: 19-May-2009 10:47:54   

ive downloaded the demo, and also examples and looked at the docs but i cant find a step by step of setting up a typical master details scenario via bindingsource within a windows forms project.

heres what ive done: - generated my classes using the selfservice model - added my collections to the toolbox - drag Master DGV onto the form and a bindingsource and my master entitycollection - hook up DGV to bindingsource, and bindingsource to entitycollection. All looks good and grid shows all columns - repeat for my details grid, except that the details bindingsource data source is the master bindingsource, with appropriate datamember property set

  • code behind as follows:
  • form_load:

    masterCollection1.GetMulti(nothing) masterCollectionBindingSource.DataSource = masterCollection1 detailCollectionBindingSource.DataSource = masterCollectionBindingSource detailCollectionBindingSource.DataMember = "qualpeople"

  • masterBindingSource_CurrentChanged:

If masterCollectionBindingSource.Position > -1 Then Dim m As masterEntity = CType(masterCollectionBindingSource.Current, masterEntity) detailCollection1.GetMultiManyToOne(Nothing, Nothing, m)

    End If

The detail grid is correctly poulated on initial load, but as soon as the master grid selection changes the detail grid clears and is not refilled. SQL Query profiler shows the correct queries running against the server but they are not showing in the grid

Im sure Im missing something pretty basic here?!

thanks

MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 19-May-2009 20:41:21   

Is there a rebind, refetch or refresh method on the grid that you can call to get it to reload itself from the datasource...?

Matt

mhollers
User
Posts: 2
Joined: 19-May-2009
# Posted on: 19-May-2009 22:36:56   

after some trial and error ive got this working:

hook up master grid, bindingsource (BS) and entity collection as initially described. The details grid is then connected to another BS with datasource=master BS, datamember="relation". no need for a detailsCollection component on the form.

form_load then simply calls masterEntityCollection.multi(nothing) to return all items in collection and windows databinding takes care of refreshing the details grid when the master grid selection changes. no need for handling BS currentChanged events as i initially was trying. Makes sense really

thanks