title: I have a gridview with a paging event. Everytime I hit a new page it makes me reload the file from the uploadfile control then it displays new page
body: <p>I want my paging to be seamless, I dont want user to have to reload file to get new pages.Where did I go wrong?</p>
  
  <pre><code>    protected void btnUpload_Click(object sender, EventArgs e)
      {
          if (Page.IsPostBack)
          {
              if (FileUpload1.PostedFile.FileName == string.Empty)
              {
  
                  return;
              }
              else
              {
                  string[] FileExt = FileUpload1.FileName.Split('.');
                  string FileEx = FileExt[FileExt.Length - 1];
                  if (FileEx.ToLower() == "csv")
                  {
                      FileUpload1.SaveAs(Server.MapPath(" " + FileUpload1.FileName));
                  }
                  else
                  {
  
                      return;
                  }
              }
              CSVReader reader = new CSVReader(FileUpload1.PostedFile.InputStream);
              string[] headers = reader.GetCSVLine();
              DataTable dt = new DataTable();
  
              foreach (string strHeader in headers)
                  dt.Columns.Add(strHeader);
              string[] data;
              while ((data = reader.GetCSVLine()) != null)
                  dt.Rows.Add(data);
              foreach (DataRow row in dt.Rows)
              {
                  string rowIdNumber = row["Sequence"].ToString();
                  string dateAndTime = row["Date and Time"].ToString();
                  string personName = row["Description #2"].ToString();
                  string doorType = row["Card number"].ToString();
  
                  DateTime dateEntered = Convert.ToDateTime(dateAndTime);
                  DoorType doorTypeEnum;
  
                  bool personExists = false;
                  foreach (object name in listboxOfNames.Items)
                  {
                      if (name.ToString() == personName)
                      {
                          personExists = true;
                          break;
                      }
                  }
                  if (!personExists)
                  {
                      listboxOfNames.Items.Add(personName);
  
                  }
                  switch (doorType)
                  {
                      case "A02 - Rear Entrance":
                          doorTypeEnum = DoorType.RearEntranceDoor;
                          break;
                      case "B12 - Exterior Main Floor Man Trap":
                          doorTypeEnum = DoorType.ExteriorMainFloorDoor;
                          break;
                      case "B12 - Interior Main Floor Man Trap":
                          doorTypeEnum = DoorType.InteriorMainFloorDoor;
                          break;
                      case "C13 - Rear Break Room Door":
                          doorTypeEnum = DoorType.RearBreakRoomDoor;
                          break;
                      case "B02 - Exterior Basement Man Trap":
                          doorTypeEnum = DoorType.ExteriorBasementDoor;
                          break;
                      case "B02 - Interior Basement Man Trap":
                          doorTypeEnum = DoorType.InteriorBasementDoor;
                          break;
                      case "D01 - Managed Services Main door":
                          doorTypeEnum = DoorType.ManagedServicesDoor;
                          break;
                      case "D01 - Managed Services Big Door":
                          doorTypeEnum = DoorType.ManagedServicesBigDoor;
                          break;
                      default:
                          doorTypeEnum = DoorType.None;
                          break;
                  }
                  peopleEntering.Add(new PersonEntered(personName, dateEntered, doorTypeEnum));
              }
  
  
              for (int i = 0; i &lt; peopleEntering.Count; i++)
              {
                  DateTime startDate = new DateTime();
                  DateTime endDate = new DateTime();
                  string personName = peopleEntering[i].PersonName;
                  if (peopleEntering[i].DoorEntered == DoorType.RearEntranceDoor)
                  {
                      startDate = peopleEntering[i].DateOfEntry;
                      for (int j = i + 1; j &lt; peopleEntering.Count; j++)
                      {
                          if (peopleEntering[j].DoorEntered == DoorType.ExteriorBasementDoor &amp;&amp; peopleEntering[j].PersonName == personName)
                          {
                              endDate = peopleEntering[j].DateOfEntry;
                          }
                      }
  
                  }
                  workSpans.Add(new WorkSpan(personName, startDate, endDate));
  
              }
  
              csvReaderGv.DataSource = dt;
              csvReaderGv.DataBind();
              listboxOfNames.Visible = true;
  
          }
  
      }
  
      protected void csvReaderGv_PageIndexChanging(object sender, GridViewPageEventArgs e)
      {
          if (Page.IsPostBack)
          {
              csvReaderGv.PageIndex = e.NewPageIndex;
              csvReaderGv.DataBind();
          }
  
      }
  </code></pre>
  
  <p>what have I done wrong? I have no I idea in my little head why I have to reload file each time I page the gridview.Please add samples or direct me to correct forum or tutorial.</p>