views:

291

answers:

1

I have an asp.net (2.0) page with a crystal report viewer. I use the following code in the page_load() method

   if (!Page.IsPostBack)
    {
      Session["REP"] = null;
    }
    ReportDocument report;
    if (Session["REP"] == null)
    {
        report = new ReportDocument();
        report.Load(Server.MapPath("reports\\rptListItems.rpt"));
        report.SetDatabaseLogon(Session["DB_USER"].ToString(), 
                                Session["DB_PWD"].ToString(), 
                                Session["DB_ODBC"].ToString(), "DBNAME");
        Session["REP"] = report;
    }
    else
    {
        report = (ReportDocument)Session["REP"];
    }
    rptItems.ReportSource = report;

When I press the 'next page' button on the toolbar of the crystal report viewer, it goes to page 2 as it should and after that it just stays there even if I press the next button again. I tried adding programatically a button which did a .ShowNextPage but that exhibited the same behaviour. What may be the reason?

In case it helps, my crystal report viewer control is declared as below

<CR:CrystalReportViewer ID="rptItems" runat="server" AutoDataBind="true"
            EnableDatabaseLogonPrompt="False" 
            EnableParameterPrompt="False" Height="50px" 
            ReuseParameterValuesOnRefresh="True" Width="800px"
            DisplayGroupTree="False" 
            HasCrystalLogo="False" />
A: 

Hello, i found the solution in other page and... it works! How? Put the code in the page_init() method. This way keeps values when navigate without the isPostBack condition.

Good luck

Fabian Ramos