HOW TO GET CRYSTAL REPORT DATA IN SESSION

Mark Devid

Total Post:102

Points:714
Posted by  Mark Devid
PHP
 1046  View(s)
Ratings:
Rate this:

I have noticed that crystal report runs the Linq query once again when the page index is changed, means when we load second page from first page? So just wanted to know if we can get which page is loaded so that we can keep values in session.

Just a hint is required as I am not getting the desired results from Google.

Update: I am sorry in a hurry I just clicked on a wrong tag. So the problem is like:

This is my code below which I use fr running my crystal report:

var rpt = new Result();                    
List<class> lst1 = new DALMethod().Get();
rpt.SetDataSource(lst1);
CRReportViewer.ReportSource = rpt;

When I switch from page one to two or more, this method in DAL is called again taking the same time it took first time to load, so I just want to have the data in session when query runs first time, and next time when I get the page index, then I will show data from session.

Is there a way around by which I can get the page index in this c# code?

  1. Royce Roy

    Post:149

    Points:1043
    Re: How to get Crystal Report data in session

    I had found the solution, hope this might help someone else: I was using a generic list as a data source:

    1.    As soon as we get to know the page loads for the first time, I mean not a postback, we can initialize a list to be maintained in session.

    2.    After showing the report we can add the data source (which is a list type).

    3.    On Report page shift data will be taken from session.

    if (!IsPostBack)

    {

     //clear session and create new session

     Session["ReportGenericList"] = null;

    }

    List<class> datasourceLst=null;

     

    if (Session["ReportGenericList"] != null)

      {

        datasourceLst= (List<class>)Session["ReportGenericList"];

      }

    else

      {

       datasourceLst = //call methods to fill datasource

       Session["ReportGenericList"] = datasourceLst;

    }

     

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!