title: Paging Selected Index Causes DataGrid Refresh
body: <p>I am making a web page with asp.net, the problem has to be with a asp:datagrid and its page index changing event. The records are displaying and paging correctly but after making a filter and reduce its grid content and trigger the page index again, the grid refreshes and came back all the other records.</p>
  <p>This is my PageLoad()</p>
  <pre><code> if (!IsPostBack)
          {
              txtDate1.Attributes.Add(&quot;placeholder&quot;, &quot;Enter Start Date  DD//MM//YY&quot;);
              txtDate2.Attributes.Add(&quot;placeholder&quot;, &quot;Enter End Date   DD//MM//YY&quot;);
              this.bindgrid();
          }
          else
              this.bindgridfilter(txtDate1.Text, txtDate2.Text);  
  </code></pre>
  <p>My bindGridsmethods()</p>
  <pre><code>   private void bindgrid()
      {
          ds = Classes.DBMethods.ShowRecords();
          grdRecords.DataSource = ds.Tables[0];
          grdRecords.DataBind();
      }
  
      private void bindgridfilter(string date1, string date2)
      {
          dsf = Classes.DBMethods.SearchBetweenDates(date1,date2);
          grdRecords.DataSource = dsf.Tables[0];
          grdRecords.DataBind();
      }
  </code></pre>
  <p>My PageIndexChanging Event</p>
  <pre><code>protected void grdRecords_PageIndexChanging(object sender, GridViewPageEventArgs e)
      {
          grdRecords.PageIndex = e.NewPageIndex;
          grdRecords.DataBind();
      }
  </code></pre>
  <p>And my FilterButton Click()</p>
  <pre><code> protected void Filter_Click(object sender, EventArgs e)
      {
          grdRecords.DataSource = null;
          bindgridfilter(txtDate1.Text, txtDate2.Text);
      }
  </code></pre>
  <p>Now it does the opposite it disappear the grid after making a change of page without a filter, and if it applies a filter now the pagination works correctly</p>