title: how search for an item in a datagrid view
body: <p>I am having a problem while searching for an item in datagridview
  here is my code but whenever i search for an item which already exist in the database, it is telling not found</p>
  
  <pre><code>If txtfirstname.Text = "" Then
      MsgBox("Please enter first name!")
  Else
      Dim totalrow As Integer = DataGridView1.RowCount - 2
      Dim rowin As Integer
      Dim flag As Boolean = False
      Dim sear As String = CStr(txtfirstname.Text)
  
      For rowin = 0 To totalrow
          Dim id As String = DataGridView1.Item(0, rowin).Value
  
          If sear = id Then
              DataGridView1.ClearSelection()
              DataGridView1.Rows(rowin).Selected = True
              DataGridView1.CurrentCell = DataGridView1.Item(0, rowin)
  
              flag = True
              Exit Sub
          Else
              flag = False
          End If
  
      Next rowin
  
      If flag = False Then
          MessageBox.Show("Firstname " &amp; txtfirstname.Text &amp; " is not found in database.", "Search Information", MessageBoxButtons.OK, MessageBoxIcon.Information)
      End If
  
  End If
  </code></pre>