title: Select row in paging gridview based on unique cell value
body: <p>I have a gridview with paging enabled and a textbox where the user can enter a string value used to select the row in the gridview with a column that matches the string value. The column's data is not the primary key and is not listed in the datakeynames.</p>
  
  <p>I've found an example that solves the problem for a non-paging gridview. In an event handler for a button control associated with the textbox:</p>
  
  <pre><code>    protected void SelFrame_Clicked(object sender, EventArgs e)
      {
          string requestedFrame = tbSelFrame.Text;
          if (requestedFrame != "")
          {
              int index = (from DataControlField col in gvFrame.Columns
                              where col.HeaderText == "Name"
                              select gvFrame.Columns.IndexOf(col)).FirstOrDefault();
  
              var query = from GridViewRow row in gvFrame.Rows
                          where row.Cells[index].Text == requestedFrame
                          select row;
              GridViewRow result = query.FirstOrDefault();
              if (result != null)
              {
                  int selectedIndex = result.DataItemIndex;
                  if (selectedIndex &gt; -1)
                      gvFrame.SelectedIndex = selectedIndex;
              }
          }
      }
  </code></pre>
  
  <p>As noted, when the value being searched is on a non-visible page of the gridview, <strong>this line returns null:</strong></p>
  
  <pre><code> GridViewRow result = query.FirstOrDefault();
  </code></pre>
  
  <p>How can I find the matching row in a gridview with paging enabled?</p>