title: GridView from CodeBehind in C# Paging not working
body: <p>when I click the > on my GridView it does not go to the next set of records.</p>
  
  <pre><code>        DataGrid dataGrid = new DataGrid();
          dataGrid.PageSize = 5;
          dataGrid.AllowPaging = true;
          dataGrid.EnableViewState = true;
          dataGrid.DataSource = customerDataTable;
          dataGrid.AllowPaging ();
          if (!IsPostBack)
          {
              dataGrid.DataBind();
          }
  </code></pre>
  
  <p>Depending on my code, it either stays on the first 5 or the grid does not show.</p>
  
  <p>I've tried the DataBind() in and out of the IsPostBack.</p>
  
  <p>I've also tried adding </p>
  
  <pre><code>        dataGrid.PageIndexChanged += new DataGridPageChangedEventHandler(dataGrid_PageIndexChanged);
  </code></pre>
  
  <p>and</p>
  
  <pre><code>    void dataGrid_PageIndexChanged(object source, DataGridPageChangedEventArgs e)
      {
          DataGrid dg = (DataGrid)source;
          dg.DataBind();
      }
  </code></pre>
  
  <p>But I can't get this to work.  What am I doing wrong?</p>
  
  <p>Thanks!</p>