title: Annoying postback and paging issue
body: <p>I asked a similar question to this but the circumstances have changed.</p>
  
  <p>I bind my gridview through code rather than on the source.</p>
  
  <p><strong>The pagination works fine, but if I click a button on second page of the gridview (after pagination), the postback is causing the pagination to reset to page 1. Can anyone tell me what I'm doing wrong?</strong></p>
  
  <p>Within my pageload i have set the !POSTBACK method as shown i.e if there is  postback event, then it shouldn't reset the grid but it does!</p>
  
  <p>Heres the onload:</p>
  
  <pre><code> protected void Page_Load(object sender, EventArgs e)
      {
          if (Session["usersName"] != null)
          {
  
              object a = Session["_id"];
  
              IDMaster = Convert.ToInt32(a);
  
              GridView1.Columns[10].Visible = true;
              GridView1.Columns[11].Visible = true;
  
          }
  
          else
          {
              GridView1.Columns[10].Visible = false;
              GridView1.Columns[11].Visible = false;
          }
  
  
  
  
          if (!IsPostBack)
          {
             BindGrid();
          }
  </code></pre>
  
  <p>The BindGrid();</p>
  
  <pre><code>           SqlConnection sqlcon = new SqlConnection(connstring);
             SqlCommand sqlcmd = new SqlCommand("select * from Coffees ORDER BY coffeeName ASC", sqlcon);
             SqlDataAdapter adp = new SqlDataAdapter(sqlcmd);
             DataSet ds = new DataSet();
             adp.Fill(ds);
             GridView1.DataSource = ds.Tables[0];
             GridView1.DataBind();
  </code></pre>
  
  <p>Page index method:</p>
  
  <pre><code> protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
      {
          GridView1.PageIndex = e.NewPageIndex;
  
          if(ViewState["searchTerm"] != null)
          {
              object a = ViewState["searchTerm"];
              string reloadTerm = a.ToString();
  
              setGrid(reloadTerm);
         }
  </code></pre>