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.
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
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;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With