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
Page  of 4 Next >>
Author Message
livez
Newbie
Newbie


Joined: 14 Feb 2008
Location: Sweden
Online Status: Offline
Posts: 17
Quote livez Replybullet Topic: Next page button not always working
    Posted: 26 Mar 2008 at 12:21am
I've created a report which I'm loading it into a CrystalReportViewer in Visual Studio 2005. When I run it though the next and previous buttons don't work correctly. It goes to page 2 ok but after that it wont move to page 3. I can type in the page number and it will go to the right page. If I'm on the last page and select the previous button it goes all the way back to page 1. 
 
Has anyone else come across this problem and perhaps solved it?


Edited by livez - 26 Mar 2008 at 12:22am
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 26 Mar 2008 at 12:39am
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).
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
livez
Newbie
Newbie


Joined: 14 Feb 2008
Location: Sweden
Online Status: Offline
Posts: 17
Quote livez Replybullet Posted: 26 Mar 2008 at 12:54am
Hello and thanks for your reply.
 
I do save the document in a session, and load it into the viewer in page_load. I find it odd that it would work for page 1 and 2 and every other funktion requiring a postback working as well, and then suddenly when I want to go to page 3 it stops working.
 
Do you think moving it to Page_Init from Page_Load could solve it? I will try it, but I will have to do some modifications to the code.


Edited by livez - 26 Mar 2008 at 12:55am
IP IP Logged
livez
Newbie
Newbie


Joined: 14 Feb 2008
Location: Sweden
Online Status: Offline
Posts: 17
Quote livez Replybullet Posted: 26 Mar 2008 at 1:56am
Problem remained :(. Iīve also noticed that this problem doesnīt occur when I run locally against the viewer in C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\ASP.NETClientFiles\Crystalreportviewers12.
 
EDIT: I also noticed another problem that only occurs when I donīt run locally. When I click on a group I donīt get a NEW tab for the group, instead my old tab with "mainreport" is replaced.


Edited by livez - 26 Mar 2008 at 1:59am
IP IP Logged
livez
Newbie
Newbie


Joined: 14 Feb 2008
Location: Sweden
Online Status: Offline
Posts: 17
Quote livez Replybullet Posted: 27 Mar 2008 at 5:13am
Thanks for your help, passing reportdocument in Page_Init instead of Page_Load solved it :)
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 27 Mar 2008 at 7:57am
Glad it worked. The problem occurs because there is a timing problem with the Viewstate data and responding to mouse clicks in the Page_Load() event. But when you put the code in the Page_Init() event then this timing issue doesn't happen and your mouse clicks on the page navigation buttons will respond correctly.

I talk about this in Chapter 14 of my CR.NET books. You can find out more about my books at Amazon.com or reading the Crystal Reports eBooks online.
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
rean
Newbie
Newbie


Joined: 07 Apr 2008
Online Status: Offline
Posts: 2
Quote rean Replybullet Posted: 07 Apr 2008 at 12:09pm
I followed the steps in ur reply but still it is  not working.
the reports are displayed based on the invoice selection made in the list box and a textbox.
I databind  my crystal report in a little method called configure crystal reports, below is my pageinit method

protected void Page_Init(object sender, EventArgs e)

{

ConfigureListBox();

ConfigureTextBox();

ConfigureCrystalReports();

if (!IsPostBack)

{Session["InRept"] = InRept;}

else

{InRept = (ReportDocument)(Session["InRept"]);}

}

what am i missing?
any help wld be appreciated.
thanks in advance
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 07 Apr 2008 at 10:01pm
First off, you can't use IsPostBack in the Init() event. This only works in the Page_Load() event. Secondly, you need to test if the Session["InRept"] = null and then call ConfigureCrystalReports(). Don't call it if it is already in the Session collection.


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
rean
Newbie
Newbie


Joined: 07 Apr 2008
Online Status: Offline
Posts: 2
Quote rean Replybullet Posted: 08 Apr 2008 at 9:52am

Brian,Thanks for replying,i did wht u suggested me to, but im still having problems. I have a textbox (where users can enter a invoice number and do a search) and a listbox which lists the invoice numbers.Evry time a make selection in the listbox or the search textbox the session for the report document "InRept" gets set to null, i dont know y its not persisting the session for the "Inrept". I have tried reorganizing my code but with no luck at all.Pls help

IP IP Logged
robarahz
Newbie
Newbie


Joined: 07 May 2008
Location: United States
Online Status: Offline
Posts: 4
Quote robarahz Replybullet Posted: 07 May 2008 at 10:00am
Hi Brian,
 
I am having the exact same issue, but moving the report loading to the Page_Init() didn't help. Could I create the report in Page_Load() which it's currently doing, store it in session, then retrieve it in Page_Init()?
 
I'm thinking there's just too much code that doesnt' execute when it's in the page_init() event.
 
Thanks for any info.
 
-Robert
IP IP Logged
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.016 seconds.