Report Design
 Crystal Reports Forum : Crystal Reports for Visual Studio 2005 and Newer : Report Design
Message Icon Topic: Next page button not always working Post Reply Post New Topic
<< Prev Page  of 4 Next >>
Author Message
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 07 May 2008 at 10:29am
I don't know why there would be code in the Page_Init() event that doesn't execute. That would be something necessary to debug. I guess your idea of initializing the report in the Page_Load() event would be okay as long as it's only done when the page loads the first time. But now you're putting similar code in two different events and there could be redundancy between them. Things start to get messy. I would think that if the Page_init() isn't executing code as expected, then the first order of business would be to debug this issue and then look at how to get Crystal working with your page.
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
IP IP Logged
robarahz
Newbie
Newbie


Joined: 07 May 2008
Location: United States
Online Status: Offline
Posts: 4
Quote robarahz Replybullet Posted: 09 May 2008 at 4:26pm
Sorry, oversight on my part. It works now.
 
Because I manually added the Page_Init(), I also had to wire it up in the InitializeCompnent() section. Once I did that, I could fire Page_Init(). I moved my code into there, and now my navigation buttons work!
 
Weird thing though, it seems as though Page_Init() fires more than once. It could be from my user controls though, not sure.
 
Thanks for the solution!
 
-Robert
IP IP Logged
xxxxx
Newbie
Newbie


Joined: 12 Sep 2008
Online Status: Offline
Posts: 1
Quote xxxxx Replybullet Posted: 12 Sep 2008 at 7:27am
hi guys

I had same problem and moving code to Page_Init() worked it out.

Here's a bit of my code in case you might need it.


Sub Page_Init()
        Try
            Dim abm As New abm
            ViewState("DataSet") = abm.returnDataSet("exec pviof.dbo.sp_printSelected '" & Request.QueryString("PVID") & "', '" & Request.QueryString("userName") & "' ")
            Dim r As New CrystalDecisions.CrystalReports.Engine.ReportDocument
            r.Load(MapPath("PVIO.rpt"))
            r.SetDataSource(ViewState("DataSet").Tables(0))
            'charger le rapport
            CrystalReportSource1.Report.FileName = "PVIO.rpt"
            CrystalReportViewer1.ReportSource = r
            CrystalReportViewer1.DataBind()
            CrystalReportViewer1.Visible = True
        Catch ex As Exception
            ProcessException(ex)
        End Try
    End Sub
IP IP Logged
jijogeorge
Newbie
Newbie
Avatar

Joined: 11 Nov 2008
Online Status: Offline
Posts: 5
Quote jijogeorge Replybullet Posted: 11 Nov 2008 at 8:23pm
Hello,

I have created one crystal report, using viewer, in asp.net. And I have created a set of .rpt files for different reports. In my application I have one combo box to select the report types, and a command button to view the report. Based on the report type, the .rpt file will be loaded and assign to the  viewer.Everything is working fine, except two problems.
1) When I Click on next page, the report will go to 2nd page only, from second page its not loading the third page, the same thing happens for the previous button.
2) I'm using one formula filed, to pass the timezone difference in sends, and need to calculate the datetime, since in DB I am storing the datetime and seconds, in GMT. So when I bind a empty datset to the report, i an getting error like the specified column is unknow.

Or is there any good method to convert the dattime, stored in seconds, from GMT to end user's timezone ?


Waiting for your reply,

Thanks in advance

Jijo George
Software Engineer,
Bangalore, India
IP IP Logged
robarahz
Newbie
Newbie


Joined: 07 May 2008
Location: United States
Online Status: Offline
Posts: 4
Quote robarahz Replybullet Posted: 12 Nov 2008 at 5:27am
Jijo,
 
For the buttons problem, refer to my post and the post of xxxxx above. If you move your report binding code from page_load to page_init in your aspx page, your buttons should work correctly.
 
I don't have an answer for your second issue, but I'm wondering if moving your data  retrieval and report binding to page_init() will take care of that problem as well.
 
Good luck.
 
Rob
IP IP Logged
jijogeorge
Newbie
Newbie
Avatar

Joined: 11 Nov 2008
Online Status: Offline
Posts: 5
Quote jijogeorge Replybullet Posted: 13 Nov 2008 at 1:35am
Thanks Rob,

The paging problem got solved and now I'm facing another problem.
I'm using the same aspx page to display various reports based on the user selection. the problem is when i generate one report and moved to 5th page, then i generated another report, which has more than 5 pages, the new report will show the 5th page. I have to click on 'show first page' to see the first page of the new report. I set ShowFirstPage() function while formatting the report viewer. the format function is calling fro  page_load event. The all the reports showing first page, but the navigation will not work properly. So can you tell me to resolve this issue?

Thanks in advance,
Jijo George
Software Engineer,
Bangalore, India
IP IP Logged
robarahz
Newbie
Newbie


Joined: 07 May 2008
Location: United States
Online Status: Offline
Posts: 4
Quote robarahz Replybullet Posted: 13 Nov 2008 at 6:14pm
Hi Jijo,
 
I'm afraid I'm at a loss with this problem that you are having. You might try some of the Microsoft forums as well. Sorry and good luck.
 
Rob
 
IP IP Logged
mwharton
Newbie
Newbie


Joined: 14 Nov 2008
Location: United States
Online Status: Offline
Posts: 1
Quote mwharton Replybullet Posted: 14 Nov 2008 at 11:01am
I am getting the same  issue using VB.NET
 
Page INIT
  configures crystal reporting
  pass parameters and report name, etc
  ya da ya da ya
 
  CrystalReportViewer1.ReportSource = crReportDocument
  Session("myReport") = crReportDocument
exit
 
 

Protected Sub Page_Load1(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

   Dim myReport As New ReportDocument

    If Page.IsPostBack Then

          myReport = CType(Session("myReport"), ReportDocument)

          CrystalReportViewer1.ReportSource = myReport

     End If

End Sub

 

 

 

 

Michael Wharton, MBA, PMP, MCDBA, MCSD, MCSE+I
www.WhartonComputer.com
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 14 Nov 2008 at 11:09am

Michael, I'm confused by the code you posted. First off, you say you have code in the Page_Init() event (yada yada) but then you show code in the Page_Load() event for handling the report.

You should never put any CR related code in the Page_Load() event. This causes timing problems with loading viewstate data into memory and gives you headaches. Secondly, if you have code in the Page_Init() event, why do you also have code in Page_Load()? Remove this code and put everything in Page_Init().
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
IP IP Logged
ErikRic
Newbie
Newbie


Joined: 17 Dec 2008
Location: Norway
Online Status: Offline
Posts: 1
Quote ErikRic Replybullet Posted: 17 Dec 2008 at 1:12am
Originally posted by BrianBischof

Two things that you probably need to do. First, put the report loading code in the Page_Init() event. Second, save the report to the Session() colletion and then retrieve it from there when the page is reloaded (Page.IsPostBack). You don't want to recreate the report every time you go to a new page (thus losing track of your current page).


Hi, and thanks for getting me one step closer to a solution. I was wondering on a couple of things, though, since I am not very experienced with ASP.NET/Web development yet.

As I understand yoursolution (pseudo description):

Page_Init()
{
    report = SomeFactoryOrOtherCodeThatGeneratesReports();

    Session["reportId"] = report;
}

Page_Load()
{
     If(Page.IsPostBack)
     {
          report = Session["reportId"];
     }
}

I understand the point of not recreating the report, but won't this happen anyway since the Page_Init() fires every time?

Either way, just moving all the code from Page_Load() to Page_Init() seems to work, but I guess this may backfire in some way?
IP IP Logged
<< Prev Page  of 4 Next >>
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.039 seconds.