E
Earl
I can write a bunch of code to use a datagridview with two related tables,
but I'm hoping to be able to use the bindingsources to do it instead. I'm
not getting any exceptions, but the datagridview is only displaying the
child columns instead of both the parent and child. What I'm doing is
setting up a strongly typed dataset, multiple bindingsources, merging data
into both tables (parent, then child) and then binding the relation to the
datagridview. Can anyone see where I'm going wrong?
Here is how I set it up in the visual designer:
1 strongly typed dataset (DSJOBS)
2 tables in the strongly typed with a relation/FK (Sales and JobSchedules)
1 datatagridview (dgv)
3 bindingsources:
SalesBindingSource (datasource = DsJobs; datamember = Sales)
ScheduleBindingSource (datasource = DsJobs; datamember = JobSchedules)
RelationBindingSource (datasource = SalesBindingSource; datamember =
FK_Sales_JobSchedules)
The code:
'this returns the PK and one other field
DsJobs.Sales.Merge(GetCurrentCustomersWithJobs())
'the FK here is related by SaleID to the Sales table, this returns all of
the JobSchedules table, including the FK
DsJobs.JobSchedules.Merge(GetJobSchedules)
'but the dgv ONLY displays the JobSchedules table
dgv.DataSource = RelationBindingSource
but I'm hoping to be able to use the bindingsources to do it instead. I'm
not getting any exceptions, but the datagridview is only displaying the
child columns instead of both the parent and child. What I'm doing is
setting up a strongly typed dataset, multiple bindingsources, merging data
into both tables (parent, then child) and then binding the relation to the
datagridview. Can anyone see where I'm going wrong?
Here is how I set it up in the visual designer:
1 strongly typed dataset (DSJOBS)
2 tables in the strongly typed with a relation/FK (Sales and JobSchedules)
1 datatagridview (dgv)
3 bindingsources:
SalesBindingSource (datasource = DsJobs; datamember = Sales)
ScheduleBindingSource (datasource = DsJobs; datamember = JobSchedules)
RelationBindingSource (datasource = SalesBindingSource; datamember =
FK_Sales_JobSchedules)
The code:
'this returns the PK and one other field
DsJobs.Sales.Merge(GetCurrentCustomersWithJobs())
'the FK here is related by SaleID to the Sales table, this returns all of
the JobSchedules table, including the FK
DsJobs.JobSchedules.Merge(GetJobSchedules)
'but the dgv ONLY displays the JobSchedules table
dgv.DataSource = RelationBindingSource