Hello guys.
Im using visual studio 2005 and access 2007 as database. I have already connect the database which have two table with two gridview in a web form (asp.net). Now i want to compared the data in the two gridview, and those who are matching should be displayed in a pop up Text box. All this should be done by clicking on a single button.
The following is the codes which i have tried and it does not work. I dont know where the problem. The following codes are for those who does not matched, which will be display. please answer should be in vb.net not C#
These codes are found inside my button "compare"
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim gv1RowCnt, gv2RowCnt As Integer
Dim diff As Boolean = False
gv1RowCnt = GridView1.Rows.Count
gv2RowCnt = GridView2.Rows.Count
Dim rw1, rw2 As GridViewRow
If gv1RowCnt > gv2RowCnt Then
For Each rw2 In GridView2.Rows
For Each rw1 In GridView1.Rows
If rw1.Cells(0).Text <> rw2.Cells(0).Text Then
diff = True
End If
Next
Next
ElseIf gv2RowCnt >= gv1RowCnt Then
For Each rw1 In GridView1.Rows
For Each rw2 In GridView2.Rows
If rw1.Cells(0).Text <> rw2.Cells(0).Text Then
diff = True
End If
Next
Next
Else
End If
Dim oAry1 As New ArrayList(New String() {})
Dim oAry2 As New ArrayList(New String() {})
Dim oAry3 As New ArrayList()
For Each i As String In oAry1
If Not oAry2.Contains(i) Then oAry3.Add(i)
Next
For Each i As String In oAry2
If Not oAry1.Contains(i) Then oAry3.Add(i)
Next
oAry3.Sort()
MsgBox(Join(oAry3.ToArray, ","))
End Sub
End Class