title: Using Session[] with Page Load
body: <p>I want to load the data into session so that when the next button is clicked in crystal report viewer then in should load the data from the datatable instead retrieving the data again from the database. Here goes my code... </p>
  
  <pre><code>   ReportDocument rpt = new ReportDocument();
      DataTable resultSet = new DataTable();
      string reportpath = null;
  
     protected void Page_Load(object sender, EventArgs e)
      {
  
  
          if (!Page.IsPostBack)
          {
  
             if (Request.QueryString.Get("id") == "5")
              {
                  string publication = Request.QueryString.Get("pub");
                  DateTime date = DateTime.Parse(Request.QueryString.Get("date"));
                  int pages = int.Parse(Request.QueryString.Get("pages"));
                  int sort = int.Parse(Request.QueryString.Get("sort"));
                  if (sort == 0)
                  {
                      reportpath = Server.MapPath("IssuesReport.rpt");
                      rpt.Load(reportpath);
                      DataTable resultSet1 = RetrievalProcedures.IssuesReport(date,          publication, pages);
                  Session["Record"] = resultSet1;
               }
  
            DataTable report = (DataTable)Session["Record"];
            rpt.SetDataSource(report);
            CrystalReportViewer1.ReportSource = rpt;
  </code></pre>
  
  <p>I am trying this code but when i clicked the next button it gives me the error that invalid report source..i guess the session is null thats why its giving me this error.</p>
  
  <p>Any sugesstions how can I solve this...</p>