In older post we have already leaned how to create and bind data in crystal report from database in asp.net we application.
Now, today we will lean how to make paging in crystal reports in asp.net using c# and vb language.
For doing paging in crystal reports first we have to create and bind data to crystal reports in asp.net.
Check link for create and bind Crystal Reports
After Creating and Binding data to crystal reports, we can do the paging in crystal reports.
For paging Details >> Selection Expert >> New Page Before
For Implement paging in crystal reports right click on details section and select Selection Expert Property.
Check the New Page Before option on selection Expert property of Details section and edit the new page before property.
– Write and save formula in New Page Before property for paging in crystal reports in asp.net.
IF Remainder (RecordNumber, 10) = 0 THEN
TRUE
ELSE
FALSE
– Write below code at Page_PreInit Event for bind the crystal reports in asp.net web forms.
C# Code
Import namespace : using CrystalDecisions.CrystalReports.Engine;
protected void Page_PreInit(object sender, EventArgs e)
{
DataSet1.STUDENT_SELECTDataTable StuDT = new DataSet1.STUDENT_SELECTDataTable();
DataSet1TableAdapters.STUDENT_SELECTTableAdapter StuAdapter = new DataSet1TableAdapters.STUDENT_SELECTTableAdapter();StuDT = StuAdapter.Select();
ReportDocument rept = new ReportDocument();rept.Load(Server.MapPath(“~/CrystalReport.rpt”));
rept.SetDataSource((DataTable)StuDT);
CrystalReportViewer1.ReportSource = rept;
}
VB.Net Code
Import namespace : Imports CrystalDecisions.CrystalReports.Engine
Dim StuDT As DataSet1.STUDENT_SELECTDataTable = New DataSet1.STUDENT_SELECTDataTable()
Dim StuAdapter As DataSet1TableAdapters.STUDENT_SELECTTableAdapter = New DataSet1TableAdapters.STUDENT_SELECTTableAdapter()StuDT = StuAdapter.Select()
Dim rept As ReportDocument = New ReportDocument()rept.Load(Server.MapPath(“~/CrystalReport.rpt”))
rept.SetDataSource(CType(StuDT, DataTable))
CrystalReportViewer1.ReportSource = rept
– Here is a out put of paging in crystal reports in asp.net