Help with merging data from two DBGrids to one DBGrid

Posted by: Victor.m.charles.civ on 18 March 2020, 5:52 am EST

    • Post Options:
    • Link

    Posted 18 March 2020, 5:52 am EST

    Hello,

    I’m musing the code below to compare two grids based on records selected in C1Data and Fields in MultiSelect1 controls. How do I modify it to matching records in both C1Data and C1DataB in C1Screen3? The code below only shows the results for C1DataB in C1Screens.

    Dim xyz1 As String = “”

    If C1Data.SelectedRows.Count > 0 Then

    If RadioButton5.Checked Then

    For iCol = 0 To C1MultiSelect1.SelectedItems.Count - 1

    For Each Srow In C1Data.SelectedRows

    xyz1 = xyz1 + “[” + C1MultiSelect1.SelectedItems(iCol).Value + “] = '” + C1Data.Columns(C1MultiSelect1.SelectedItems(iCol).Value).CellText(Srow) + "’ OR "

    Next

    Next

    xyz1 = xyz1.Remove(xyz1.Length - 4, 4)

    Console.WriteLine(xyz1)

    End If

                If RadioButton6.Checked Then
                    For Each Srow In C1Data.SelectedRows
                        For iCol = 0 To C1MultiSelect1.SelectedItems.Count - 1
                            xyz1 = xyz1 + "[" + C1MultiSelect1.SelectedItems(iCol).Value + "] = '" + C1Data.Columns(C1MultiSelect1.SelectedItems(iCol).Value).CellText(Srow) + "' AND "
                        Next
                        xyz1 = xyz1.Remove(xyz1.Length - 4, 4)
                        xyz1 = xyz1 + "OR "
                    Next
                    xyz1 = xyz1.Remove(xyz1.Length - 4, 4)
                    Console.WriteLine(xyz1)
                End If
            End If
            Dim FilteredDTA1 As DataTable
            FilteredDTA1 = C1DataB.DataSource
            Dim view51 As DataView
            view51 = New DataView(FilteredDTA1)
            view51.RowFilter = xyz1
            C1Screen3.DataSource = view51
    

    Thanks,

    Victor

  • Posted 18 March 2020, 7:54 pm EST

    Hi Victor,

    The code snippet provided by you has numbers of unknowns like C1Data, C1DataB, C1Screen3… Please provide us a stripped-down sample of your application so that we can replicate the issue and provide you a helpful solution.

    As per the last line of the code snippet you provided I would suggest you to add rows from C1Data to the FilteredDTA1 DataTable this will help you to include all the rows from both the grids so that you can get the records from both the girds.

    Regards,

    Prabhat Sharma.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels