简体   繁体   English

Crystal Report Viewer的参数面板为空

[英]Crystal Report Viewer's parameter panel is empty

I'm using Crystal Reports 13 SP 13 in Visual Studio 2010. The report is viewed in an aspx.net web page. 我在Visual Studio 2010中使用Crystal Reports 13 SP13。该报告在aspx.net网页中查看。 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. 我当前的实现使用从DataSet创建的DataTable。 The report is stored in a Session variable. 该报告存储在Session变量中。 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. 尝试将ParameterFieldUsage2属性设置为ShowOnPanel时,系统引发System.NotSupportedException。

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. 但这有效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM