title: GridView Paging Issue
body: <p>I am using a gridview control and performing Paging and Sorting manually.
  Here is the method of Paging:</p>
  
  <pre><code>protected void gdvMainList_PageIndexChanging(object sender, GridViewPageEventArgs e)
      {
          gdvMainList.PageIndex = e.NewPageIndex;
          gdvMainList.DataSource = dtConsentReleaseList;
          gdvMainList.DataBind();
      }
  </code></pre>
  
  <p>I have a static datatable having a column Id:</p>
  
  <pre><code>dtConsentReleaseList.Columns.Add("Id");
              dtConsentReleaseList.Columns.Add("StartDate");
              dtConsentReleaseList.Columns.Add("EndDate");
              dtConsentReleaseList.Columns.Add("Contact");
  </code></pre>
  
  <p>I am assigning datakeynames "Id" in my GridView.
  And I also have a print button in each row. When I click that button, this code gets executed:</p>
  
  <pre><code>else if (e.CommandName == "New")
          {                
              int selectedIndex = Convert.ToInt32(e.CommandArgument);
              int consentReleaseId = Convert.ToInt32(gdvMainList.DataKeys[selectedIndex].Value);
              string openReportScript = Utility.OpenReport(ResolveClientUrl("~/Reports/Consumer/ConsentReleaseReport.aspx?Id=" + consentReleaseId + "&amp;ReportTitle=ConsentForRelease"));
              ScriptManager.RegisterClientScriptBlock(upConsentRelease, upConsentRelease.GetType(), "Pop up", openReportScript, true);
          }
  </code></pre>
  
  <p>but when I change the page and clicks print button, an exception occurs on this line : </p>
  
  <pre><code>int consentReleaseId = Convert.ToInt32(gdvMainList.DataKeys[selectedIndex].Value);
  </code></pre>
  
  <p>Exception is:</p>
  
  <pre><code>Index was out of range. Must be non-negative and less than the size of the collection.Parameter name: index
  </code></pre>
  
  <p>I guess I am doing something wrong in Paging method.</p>
  
  <p>Any help please?</p>