0
votes

I'm using Crystal Reports 13 SP 13 in Visual Studio 2010. The report is viewed in an aspx.net web page. What I want is for the report to prompt for a parameter before it loads, and then the user can select a new parameter and view other records from it. I've verified that my parameter, a drop down list, is working as intended.

I've set the parameter to be 'editable', but nothing is in the panel. In fact, if I allow the group tree panel and button to be shown, there is no button to click for the parameter panel at all.

Oddly enough, as I was struggling with my previous issues, have the user change their parameter in that panel was one of the things that worked.

My current implementation uses a DataTable created from a DataSet. The report is stored in a Session variable. If I had to guess, it is one of these things that's giving me my new problem.

I've found some interesting code here.

foreach (CrystalDecisions.Shared.ParameterField parameterField in reportDocument.ParameterFields)
{

  parameterField.ParameterFieldUsage2 = ParameterFieldUsage2.ShowOnPanel;

}

Unfortunately, like the poster of that thread this code doesn't work for me. The system throws a System.NotSupportedException when trying to set the ParameterFieldUsage2 property to ShowOnPanel.

1

1 Answers

0
votes

So it turns out that sessions were the problem all along. For whatever reason, you can't update the parameters when the report is stored in a session variable.

So for that I had to change up my implementation once again.

private ReportDocument rpt;
private myDataSet ds;

protected void Page_Init(object sender, EventArgs e)
{

    DataTable dt = new DataTable();
    ds = new myDataSet();
    myDataSetTableAdapters.myTableTableAdapter dsTA = new myDataSetTableAdapters.myTableTableAdapter();
    dt = dsTA.GetData();

    rpt = new ReportDocument();
    rpt.Load(Server.MapPath(mapPath));
    rpt.SetDataSource(dt);
    CrystalReportViewer1.ReportSource = rpt;

}

That's it. That's all I needed for this to work. No more worrying about post backs, or sessions. After everything I went through to get here I don't quite understand how this can be so simple. But it works.