C#, Crystal Reports parameter dialog displays randomly


I assign Crystal Reports parameter values and the report displays great with no dialog popups, but sometimes the dialog just appears for no reason and I cannot figure out why.
I run a report and it works great, I keep the same parameter values and sometimes change them, but the dialog still only appears randomly.

Please see my code below. This code is only code that is relevant to handling my parameters. I removed any other unnecessary code.

public partial class frm_ReportViewer : Form
        CrystalDecisions.CrystalReports.Engine.ReportDocument myReport = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

        private const string PARAMETER_REPORT_HEADER = "ReportHeader";

	private void frm_ReportViewer_Load(object sender, EventArgs e)
        	string reportPath = "";
        	ArrayList arrayListreportheader = new ArrayList();
		reportPath = Application.StartupPath + "\\" + "creport.rpt";
                arrayListreportheader.Add("Header text here");

                //SQL query and fill dataset here

		crystalReportViewer1.ReportSource = myReport;
	        ParameterFields parameterFields = myReport.ParameterFields;
       		SetReportHeaderParameterField(parameterFields, arrayListreportheader);

private void SetReportHeaderParameterField(ParameterFields parameterFields, ArrayList arrayList)
            ParameterField parameterField = parameterFields[PARAMETER_REPORT_HEADER];
            ParameterValues currentParameterValues = new ParameterValues();

            foreach (object submittedValue in arrayList)
                ParameterDiscreteValue parameterDiscreteValue = new ParameterDiscreteValue();
                parameterDiscreteValue.Value = submittedValue.ToString();

            parameterField.CurrentValues = currentParameterValues;

Open in new window

Who is Participating?
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.

What if for the last line in your frm_ReportViewer_Load you refresh the crystal report?
DeonMAuthor Commented:
That produces the dialog popup every time then.
I moved Line:19 to Line: 23 and thus far i haven't received the dialog once.
Will need to test more though to confirm if this indeed has fixed the problem. This change makes more sense as well, but I know I wrote this sequence for a reason awhile back.

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
That was going to be my next suggestion. I've always run into crystal report parameter problems like the one you are experiencing, and i usually solve it with a refresh somewhere, or mvoing where i change the report source.
If you refresh, Crystal will drop the assigned parameter values and prompt for new values.

DO all parameters get legal values?

I think your idea of moving the reportsource assignment is the answer.

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

From novice to tech pro — start learning today.