title: How to compare row values of two gridviews with dropdownlist column in asp.net?
body: <p>I have two gridviews. The first one has a dropdownlist. When a user clicks a button named 'Show' data will be displayed on both gridviews where data comes from database. The row data on column with dropdownlist must be compared to the rows on the first column of the second gridview. If they are equal a messagebox will prompt saying that there's no changes and data will not be saved, else if they are not equal modal pop-up will be displayed asking if data are correct.</p>
  
  <p>Below is my code for comparing but it only reads the value of the 1st row in gridview1.</p>
  
  <pre><code> For i = 0 To GridView1.Rows.Count - 1
  
              Dim ddl As DropDownList = DirectCast(GridView1.Rows(i).Cells(6).FindControl("dropdowncriteria"), DropDownList)
              Dim txt As TextBox = DirectCast(GridView1.Rows(i).Cells(7).FindControl("txtreason"), TextBox)
  
  
              If ddl.SelectedValue = GridView2.Rows(i).Cells(0).Text And txt.Text = GridView2.Rows(i).Cells(1).Text Then
  
                  MessageBox("No Changes Made! Nothing will be Saved.")
                  Return
  
              Else
  
                  lblmsg.Text = "Are you sure that all the Data you've Selected/Entered are Correct?"
                  mdlpopupmsg.Show()
                  Return
  
              End If
  
    Next
  </code></pre>
  
  <p>What must be the problem on this?</p>
  
  <p>Thanks in advance.</p>