Crystal Reports Viewer won't go past page 2
Solution 1
The problem may stem from setting the Crystal Report Viewer control's ReportSource
during the Page_Load
event. This causes the paging information to be over-written with each page load, so the "current page" is re-set to 1 when it should be at 2.
As an easy solution, you can move the code that sets ReportSource
into Page_Init
Solution 2
Manually add the Page_Init() event and wire it up in the InitializeCompnent() with
this.Init += new System.EventHandler(this.Page_Init).
Move the contents of Page_Load
to Page_Init()
.
Add if (!IsPostBack)
condition in PageInIt.
protected void Page_Init(object sender, EventArgs e) {
if (!IsPostBack)
{
ReportDocument crystalReportDocument = new ReportDocumment();
crystalReportDocument.SetDataSource(DataTableHere);
_reportViewer.ReportSource = crystalReportDocument;
Session["ReportDocument"] = crystalReportDocument;
}
else
{
ReportDocument doc = (ReportDocument)Session["ReportDocument"];
_reportViewer.ReportSource = doc;
}
}
Solution 3
if (!Page.IsPostBack)
{
//Write your Report display code
crystalRep.Load(Server.MapPath("DueFD.rpt"));
crystalRep.SetDatabaseLogon(DB_UId, DB_Pass, Serv_Name, DB_Name);
CrystalReportViewer1.ReportSource = crystalRep;
// session code
ReportDocument doc = (ReportDocument)Session["ReportDocument"];
CrystalReportViewer1.ReportSource = doc;
}
else
{
ReportDocument doc = (ReportDocument)Session["ReportDocument"];
CrystalReportViewer1.ReportSource = doc;
}
Solution 4
Put Report Source in Page_Init instead of Page_Load And report parameters Page_Load I think it works Probably
Solution 5
It works for me!!
ReportDocument rd = new ReportDocument();
protected void Page_Load(object sender, EventArgs e)
{
string rptpath = WebConfigurationManager.AppSettings["ReportPath"].Replace("{TID}", Convert.ToString(Session["TID"]));
rd.Load(rptpath);
DataTable dtable = TemplateModel.LoadChequeData(Convert.ToString(Session["CID"]));
rd.SetDataSource(dtable);
}
protected void Page_Init(object sender, EventArgs e)
{
CrystalReportViewer1.ReportSource = rd;
}
Dominic Gagné
I write code for a living, primarily as a C#/ASP.NET consultant. I also play roller derby and am bad at guitar.
Updated on June 14, 2022Comments
-
Dominic Gagné almost 2 years
I have a Crystal Report Viewer control on an aspx page, which is supposed to have built-in paging.
When I click the "next page" button the first time, I move from page 1 to page 2, but every other time I click "next page" the report reloads to page 2.
-
stillsmallvoice almost 8 yearsMoving to Page_Init does solve the problem, but now I'm having an issue closing its report source. I would like to call these methods report.Close(); report.Dispose(); But I can't call them during Page_Init. Without closing the connections, I get this error after users use the report for a while: Crystal Reports Exception: The maximum report processing jobs limit configured by your system administrator has been reached
-
Ramunas over 7 yearsThanks., best answer.
-
Marc L. over 7 years@stillsmallvoice Use a field for the report source instead of a local variable, and dispose of it in the page
Dispose()
override.