Crystal Reports Parameters not being used when printing from CrystalReportsViewer

Hi,

I have a number of Crystal Reports running from .Net 4 webpages, when I view the reports on screen using the CrystalReportsViewer and change the parameters it's all fine but when I try to either Export or Print the report it reverts back to using the parameter I last used when saving the actual report.

I have tried loads of things, not saving data in with the report, that just refreshes the page, setting refresh DB connections in the report and to be honest to many other things but I just can't get the report to use the parameter I select from the web page.

Any ideas on how to make it work? I have attached the report code from the aspx page and also the code from the .cs file that is attached just incase this gives anyone any clues.

Any help would be really appreciated.

Regards,

Ken

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using CrystalDecisions.Web;
using CrystalDecisions;

namespace TarweejV4.Internal.PO.Forms
{
    public partial class VMF1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
           
        }

        protected void CrystalReportViewer1_Load(object sender, EventArgs e)
        {
            ReportDocument report = new ReportDocument();
            report.Load(Server.MapPath("~/Internal/PO/FORMS/VMF.rpt"));
            report.SetDatabaseLogon("sa", "password", @"192.168.100.56", "T1");
            CrystalReportViewer1.ReportSource = report;
           
        }
    }

Open in new window

<CR:CrystalReportSource ID="VMF" runat="server">
        <Report FileName="~\Internal\PO\Forms\VMF.rpt">
        </Report>
    </CR:CrystalReportSource>
    <CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" 
        AutoDataBind="true" ReportSourceID="VMF" 
        ToolPanelView="ParameterPanel" onload="CrystalReportViewer1_Load" 
        HasRefreshButton="True" HasCrystalLogo="False"/>
</asp:Content>

Open in new window

kenuk110Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mlmccCommented:
If you are exporting or printing from th eviewer it causes a postback which you have to handle.
You need to save the parameter values in session variables and reload them before exporting the report.

mlmcc
0
kenuk110Author Commented:
Hi,

I see, the next question is do you know how to do this, I'm not a programmer to be honest, do you have any advice on how I do this or a page on the net I could read??

Thanks in advance.

Ken
0
kenuk110Author Commented:
Hi mimcc,

Do you have any references I can try to use to figure this out, I understand what you are telling me but I'm at a loss how to proceed, I just don't know how to program this, I can however follow instruction and pass back information if that helps?

Regards,

Ken
0
Introduction to R

R is considered the predominant language for data scientist and statisticians. Learn how to use R for your own data science projects.

mlmccCommented:
I am not a .Net programmer so I haven't had to del with the issue.  I'll try to find sample code.

mlmcc
0
mlmccCommented:
THis tutorial covers the issue.  Search for postback

http://www.businessobjects.com/global/pdf/dev_zone/VS2005_Walkthroughs.pdf

mlmcc
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
kenuk110Author Commented:
Thanks mimcc, I downloaded that PDF, printed it then found the place relating to Sessions. I clicked and deleted and edited and built 1000 times then finaly I got it working. Here is what I had to do just incase anyone else has this problem:

 protected void CrystalReportViewer1_Load(object sender, EventArgs e)
         {
            if (Session["Session"] == null)
            {
                ReportDocument DCS = new ReportDocument();
                DCS.Load(Server.MapPath("~/Internal/PO/FORMS/DCS.rpt"));
                DCS.SetDatabaseLogon("sa", "password", @"192.168.100.10", "T1");
                CrystalReportViewer1.ReportSource = DCS;
                Session["Session"] = DCS;
            }
            else
            {
                ReportDocument DCS = (ReportDocument)Session["Session"];
                DCS.Load(Server.MapPath("~/Internal/PO/FORMS/DCS.rpt"));
                DCS.SetDatabaseLogon("sa", "password", @"192.168.100.10", "T1");
                CrystalReportViewer1.ReportSource = DCS;
            }

        }


You have to add the report to a session, if it's null then build it as is but save it then it uses the parameters you selected throughout your time looking at the report, printing and exporting works perfectly now.

Thanks so much for you post.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Crystal Reports

From novice to tech pro — start learning today.