Hi All,
I'm developing an ASP.NET application that allows users to view and download reports. I'm using Crystal Reports 10. To view reports on the browser, I'm using a Web Forms Viewer (CrystalDecisions.Web.CrystalReportViewer). This Web Forms viewer displays some nasty navigational buttons which I hate, and so I decided to create my own navigational "Prev/Next" buttons. Thus, I have two button controls on my form and, not surprisingly, their text properties are set to "Prev Page" and "Next Page", respectively.
I would like to disable the Prev button when the user is at the first page because there are no more pages before the first one (duh!). To do this, I keep track of the current page in a Session variable and disable the "Prev" button when the page becomes 1. Like this:
Alright, the code is straight forward; if the page becomes one, disable the Prev button so that the user knows he's in the first page.
Now, enough of that. My problem comes in when I have to do this for the "Next" button. I have to disable it when I'm at the last page (so that the user knows there are no more pages to view), but I don't know what the last page is because the Web Forms Viewer doesn't seem to expose a property for it. Therefore, I can't disable the "Next" button when I'm at the last page. Check this code out:
When the user gets to the last page, if he clicks next he'll just get the same page again. And let me tell you, he could click as many times as he wants and he'll get the same page over and over.
Can anybody tell me how I can get the total number pages in a Web Forms Viewer?
Thanks!
JC
We don't see things as they are; we see them as we are. - Anais Nin
I'm developing an ASP.NET application that allows users to view and download reports. I'm using Crystal Reports 10. To view reports on the browser, I'm using a Web Forms Viewer (CrystalDecisions.Web.CrystalReportViewer). This Web Forms viewer displays some nasty navigational buttons which I hate, and so I decided to create my own navigational "Prev/Next" buttons. Thus, I have two button controls on my form and, not surprisingly, their text properties are set to "Prev Page" and "Next Page", respectively.
I would like to disable the Prev button when the user is at the first page because there are no more pages before the first one (duh!). To do this, I keep track of the current page in a Session variable and disable the "Prev" button when the page becomes 1. Like this:
Code:
[COLOR=blue]int[/color] page = ([COLOR=blue]int[/color])Session["page"];
[COLOR=blue]if[/color] (page > 1)
{
page--;
[COLOR=green]// reportVr is the Web Forms viewer[/color]
reportVr.ShowNthPage(page);
Session["page"] = page;
[COLOR=blue]if[/color] (page == 1)
[COLOR=green]// Disable "Prev" button[/color]
btnPrev.Enabled = [COLOR=blue]false[/color];
}
Now, enough of that. My problem comes in when I have to do this for the "Next" button. I have to disable it when I'm at the last page (so that the user knows there are no more pages to view), but I don't know what the last page is because the Web Forms Viewer doesn't seem to expose a property for it. Therefore, I can't disable the "Next" button when I'm at the last page. Check this code out:
Code:
[COLOR=blue]int[/color] page = ([COLOR=blue]int[/color])Session["page"];
[COLOR=blue]if[/color] (page < [COLOR=red][hmmm ???][/color])
{
page++;
[COLOR=green]// reportVr is the Web Forms viewer[/color]
reportVr.ShowNthPage(page);
Session["page"] = page;
[COLOR=blue]if[/color] (page == [COLOR=red][hmmm ???][/color])
[COLOR=green]// Disable "Prev" button[/color]
btnNext.Enabled = [COLOR=blue]false[/color];
}
Can anybody tell me how I can get the total number pages in a Web Forms Viewer?
Thanks!
JC
We don't see things as they are; we see them as we are. - Anais Nin