vb.net - Show child data in a DataGridView control related to multiple parent entity records -
i have vb winforms form 3 bindingsource controls, each showing data (via datagridviews or bound textboxes) 3 related entities created db first.
i need have datagridview showing & allowing adding/editing/deleting tbl_distribution_dealermodel_overalts records related both current tbl_primarydealergroup record (joining on fields tbl_primarydealergroup.dealergroupid = tbl_distribution_dealermodels_overalts.firstdealergroupid) , current tbl_seriesmanufacturer record (joining on 2 common fields: aus_series_cde , manufacturerid). tbl_distribution_dealermodel_overalts on many-side of relationships 2 other tables:

how can have child entity's datagridview show records related each of 2 (or more) parent entity records? may necessary me relate child entity 3 or more parents in project, generically applicable answers appreciated
i sorted out myself:
private sub bs_tblsm_tblpdg_currentchanged(sender system.object, e system.eventargs) handles bs_tbl_series_manufacturer.currentchanged, bs_tbl_primarydealergroup.currentchanged if bs_tbl_series_manufacturer.current isnot nothing , bs_tbl_primarydealergroup.current isnot nothing dim series string = bs_tbl_series_manufacturer.getitemproperties(nothing)("aus_series_cde").getvalue(bs_tbl_series_manufacturer.current) dim manufacturer byte = bs_tbl_series_manufacturer.getitemproperties(nothing)("manufacturerid").getvalue(bs_tbl_series_manufacturer.current) dim pdg integer = bs_tbl_primarydealergroup.getitemproperties(nothing)("dealergroupid").getvalue(bs_tbl_primarydealergroup.current) dim changefilter boolean = false if m_currentseries <> series m_currentseries = series changefilter = true end if if m_currentmanufacturer <> manufacturer m_currentmanufacturer = manufacturer changefilter = true end if if m_currentpdg <> pdg m_currentpdg = pdg changefilter = true end if if changefilter dim dlrmdloveralts ienumerable(of tbl_distribution_dealermodel_overalts) dlrmdloveralts = ddmoa tbl_distribution_dealermodel_overalts in m_context.tbl_distribution_dealermodel_overalts.local.tobindinglist _ ddmoa.aus_series_cde = m_currentseries , ddmoa.manufacturerid = m_currentmanufacturer , ddmoa.firstdealergroupid = m_currentpdg _ select ddmoa bs_tbl_distribution_dealermodel_overalts.datasource = dlrmdloveralts.tolist me.dgvtbcdealermodeloveralts_aus_series_cde.defaultcellstyle.nullvalue = m_currentseries.tostring me.dgvtbcdealermodeloveralts_manufacturerid.defaultcellstyle.nullvalue = m_currentmanufacturer.tostring me.dgvtbcdealermodeloveralts_firstdealergroupid.defaultcellstyle.nullvalue = m_currentpdg.tostring bs_tbl_distribution_dealermodel_overalts.resetbindings(false) changefilter = false end if end if end sub the trick not try use datamembers of parent bindingsources in child bindingsource, relate entities in code in currentchanged of both parent bindingsources.
Comments
Post a Comment