When clicking the 'Next' navigation button while on page 1 of the report, page 2 appears. However, when clicking the 'Next' navigation button while on page 2, page 2 is returned again.
On reading other articles on this forum I was advised to try binding in the Page_Init().
I've tried this solution of rebinding the CrystalReportViewer control in Page_Init() but I still can't page past page two on a five page document. In debugging the code correctly comes into Page_Init() , my session still holds the document but nothing happens.
My Page_Init():
protected void Page_Init(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
i was having this same problem with the next button(paging in CR) in the crystal report viewer, i have read several posts on difft website asking me to put the crystal report in a session, but evry time there is a post back from the listbox or textbox the
session for the report gets set to a null. A brief description abt my application i have a listbox that displays invoice numbers and evry time a user clicks on an invoice number it displays teh invoice using CR.I also have a texbox which serves the purpose
of a search, type in the invoice number in the textbox and hit the search button it shd display up the corresponding report. I have a method called configure crystal report which contains the code that databinds the CR to the data source and all other settings
necessary for configuring a CR.I call this method in the listbox selected index changed and button click evnt of the search button. here is snapshot of my code
I figured out another soln. not sure if this is the absolute one,On the onload event for the crystal report i gave the name of the selected index change event for the listbox. It worked well from there on without any problems. im mentioning the details below.
double click the list box, the listbox SelectedIndexChanged is created in the code behind, copy the name of this event and paste it in the onload event of the crytsal report viewer in the html page.
jimmyfingers...
Member
10 Points
32 Posts
CrystalReportViewer Paging Problem
Mar 19, 2008 04:16 PM|LINK
HI,
When clicking the 'Next' navigation button while on page 1 of the report, page 2 appears. However, when clicking the 'Next' navigation button while on page 2, page 2 is returned again.
On reading other articles on this forum I was advised to try binding in the Page_Init().
I've tried this solution of rebinding the CrystalReportViewer control in Page_Init() but I still can't page past page two on a five page document. In debugging the code correctly comes into Page_Init() , my session still holds the document but nothing happens. My Page_Init():
protected void Page_Init(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
}
else
{
if (Session["reportDocument"] != null)
{
crViewer1.ReportSource = Session["reportDocument"];
crViewer1.DataBind();
}
}
}
rean
Member
30 Points
43 Posts
Re: CrystalReportViewer Paging Problem
Apr 08, 2008 06:21 PM|LINK
did u solve the problem
i was having this same problem with the next button(paging in CR) in the crystal report viewer, i have read several posts on difft website asking me to put the crystal report in a session, but evry time there is a post back from the listbox or textbox the session for the report gets set to a null. A brief description abt my application i have a listbox that displays invoice numbers and evry time a user clicks on an invoice number it displays teh invoice using CR.I also have a texbox which serves the purpose of a search, type in the invoice number in the textbox and hit the search button it shd display up the corresponding report. I have a method called configure crystal report which contains the code that databinds the CR to the data source and all other settings necessary for configuring a CR.I call this method in the listbox selected index changed and button click evnt of the search button. here is snapshot of my code
protected void btnSearch_Click(object sender, ImageClickEventArgs e)
{
if(isvalidinvoicenumber)
{
Session["TEXTBOXENTRY"] = SearchTextbox.Text.Trim();
ConfigureCrystalReports();
Session["InRept"] = InRept;//InRept is the report document
}
}
protected void InvoiceListBox_SelectedIndexChanged(object sender, EventArgs e)
{
Session["InvoiceNumber"] = InvoiceListBox.Text;
ConfigureCrystalReports();
Session["InRept"] = InRept;
}
private void ConfigureCrystalReports()
{
InRept = new ReportDocument();
string reportPath = Server.MapPath("InvoiceReport.rpt");
InRept.Load(reportPath);
CrystalReportViewer1.DisplayToolbar = true;
CrystalReportViewer1.HasSearchButton = true;
CrystalReportViewer1.HasExportButton = true;
CrystalReportViewer1.HasPrintButton = true;
CrystalReportViewer1.HasPageNavigationButtons = true;
CrystalReportViewer1.ShowPreviousPage();
CrystalReportViewer1.ShowNextPage();
DataSet dataSet = dataconfig.dataset1;
InRept.SetDataSource(dataSet);
CrystalReportViewer1.ReportSource = InRept;
ParameterValues myparamValues = new ParameterValues();
ParameterDiscreteValue myparamDiscreteValue = new ParameterDiscreteValue();
if (_Default.TextBoxSet == true)
{
myparamDiscreteValue.Value = Convert.ToString(System.Web.HttpContext.Current.Session["TEXTBOXENTRY"]);
_Default.TextBoxSet = false;
}
else
{ myparamDiscreteValue.Value = Convert.ToString(System.Web.HttpContext.Current.Session["InvoiceNumber"]); }
myparamValues.Add(myparamDiscreteValue);
InRept.DataDefinition.ParameterFields["@InvoiceNum"].ApplyCurrentValues(myparamValues);
CrystalReportViewer1.DataBind();
}
I know im going wrong somewhere, but unable to pin point it.
any help wold be appreciated.
thanx in advance
rean
Member
30 Points
43 Posts
Re: CrystalReportViewer Paging Problem
Apr 14, 2008 06:59 PM|LINK
I figured out another soln. not sure if this is the absolute one,On the onload event for the crystal report i gave the name of the selected index change event for the listbox. It worked well from there on without any problems. im mentioning the details below.
double click the list box, the listbox SelectedIndexChanged is created in the code behind, copy the name of this event and paste it in the onload event of the crytsal report viewer in the html page.
<CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" Height="50px" Width="600px" PrintMode="ActiveX" HasSearchButton="False" AutoDataBind="True" ReuseParameterValuesOnRefresh="True" ShowAllPageIds="True" OnLoad="ListBox_SelectedIndexChanged"/>hope this helps anyone still struggling with this issue