Click here to Skip to main content
15,122,406 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have below mentioned code in which I have to select date first & on that selection basis on button click report will be displayed, I am facing issue that after second page navigation is not working I can move to last page or manually enter the page number but navigation next & previous page not working.

Please check my code & suggest correction

What I have tried:

Private objRpt As New ReportDocument
    Protected Sub Page_PreInit(sender As Object, e As EventArgs) Handles Me.Load
        If IsPostBack = False Then
            'objRpt.Load(Server.MapPath("~/Pending.rpt"))
            'CrystalReportViewer1.ReportSource = objRpt
        Else
            '           objRpt = CType(Session("reportDocument"), ReportDocument)
            objRpt = Session("reportDocument")
            CrystalReportViewer1.ReportSource = objRpt
        End If
    End Sub

    Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

        Dim strConnString As String = ConfigurationManager.ConnectionStrings("constr").ConnectionString
        Dim dat As String = TextBox1.Text
        Dim ds As New DataSet
        Dim cnn As SqlConnection
        Dim sql As String
        cnn = New SqlConnection(strConnString)
        cnn.Open()
        sql = "SELECT * from Pending_Entries where pen_dt=cast('" & dat & "'AS date)"
        Dim dscmd As New SqlDataAdapter(sql, cnn)
        dscmd.Fill(ds, "Product")
        ' MsgBox(ds.Tables(1).Rows.Count)
        cnn.Close()
        Dim objRpt As New ReportDocument
        objRpt.Load(Server.MapPath("~/Pending.rpt"))
        objRpt.SetDataSource(ds.Tables(1))
        Session("reportDocument") = objRpt
        CrystalReportViewer1.ReportSource = objRpt
        CrystalReportViewer1.ToolPanelView = ToolPanelViewType.None
        CrystalReportViewer1.BestFitPage = False
        CrystalReportViewer1.Width = 900
        CrystalReportViewer1.Height = 600
    End Sub
Posted
Updated 6-Jan-21 5:32am
v2

1 solution

This article explains & gives the solution
Crystal Reports Page navigation not working after 2nd Page in ASP.Net[^]
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900