Compare GridView Data in ASP.NET

Consider we have 3 Grids G1, G2, G3. And we are displaying data in G1 and G2. We will display those records in G3 which are not present in G2 as compared to G1.
 
Here we are checking first column value of G1 to first column value of G2 and adding records to list as per condition. Here is the code: 
  1. List<int> newLists = new List<int>();  
  2.    
  3. //iterate first gridview  
  4. foreach (GridViewRow row1 in G1.Rows)  
  5. {  
  6.    if (row1.RowType == DataControlRowType.DataRow)  
  7.    {  
  8.       string gv1Value = row1.Cells[0].Text;  
  9.       //iterate second gridview  
  10.       foreach (GridViewRow row2 in G2.Rows)  
  11.       {  
  12.          if (row2.RowType == DataControlRowType.DataRow)  
  13.          {  
  14.             string gv2Value = row2.Cells[0].Text;  
  15.             //do comparison here  
  16.             if (!gv1Value.Contains(gv2Value))  
  17.             {  
  18.                //if your criteria are met, put the data in the new lists  
  19.                newLists.Add(Convert.ToInt32(gv1Value));  
  20.             }  
  21.          }  
  22.       }  
  23.    }  
  24. }  
  25.    
  26. if (newLists.Count > 0)  
  27. {  
  28.    G3.DataSource = newLists;  
  29.    G3.DataBind();  
  30. }    
Hope this Code Snippet will help you.