Crystal Report Viewer的参数面板为空

时间:2015-05-20 22:19:27

标签: c# crystal-reports

我在Visual Studio 2010中使用Crystal Reports 13 SP 13.该报告在aspx.net网页中查看。我想要的是报告在加载之前提示参数,然后用户可以选择一个新参数并从中查看其他记录。我已经验证我的参数(下拉列表)按预期工作。

我已将参数设置为“可编辑”,但面板中没有任何内容。实际上,如果我允许显示组树面板和按钮,则根本没有按钮可以单击参数面板。

奇怪的是,当我在解决之前的问题时,让用户在该面板中更改其参数是其中一项有效的方法。

我当前的实现使用从DataSet创建的DataTable。该报告存储在Session变量中。如果我不得不猜测,这就是其中一件让我遇到新问题的事情。

我找到了一些有趣的代码here

>>> datetime.datetime.combine(datetime.date.today(), time.strptime("03:40:01 PM", "%I:%M:%S %p"))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: combine() argument 2 must be datetime.time, not time.struct_time
>>> datetime.datetime.combine(datetime.date.today(), datetime.time.strptime("03:40:01 PM", "%I:%M:%S %p"))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: type object 'datetime.time' has no attribute 'strptime'

不幸的是,就像那个帖子的海报一样,这段代码对我不起作用。尝试将ParameterFieldUsage2属性设置为ShowOnPanel时,系统抛出System.NotSupportedException。

1 个答案:

答案 0 :(得分:0)

事实证明,会话一直都是问题所在。无论出于何种原因,当报表存储在会话变量中时,您无法更新参数。

因此,我必须再次更改我的实现。

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;

}

那就是它。这就是我需要的全部工作。不再担心回帖或会话。在我到达这里的所有事情之后,我不太明白这是如何如此简单。但它确实有效。

相关问题