RDLC报表一直在加载而没有显示数据

4

我希望手动向数据集中添加值生成rdlc报告,因为我将日期作为查询的输入参数。我使用以下代码实现:

//my list get populated with the relevant records according to its date and I'm using the tableadapter of my dataset to do that

List<DailySalesEntity> list = DailySalesHandler.GetSalesByDate(dateTimePicker1.Value);
            reportViewer1.LocalReport.DataSources.Clear();
            Microsoft.Reporting.WinForms.ReportDataSource report = new Microsoft.Reporting.WinForms.ReportDataSource("DataSet_Dailysales", list);
            reportViewer1.LocalReport.DataSources.Add(report);
            reportViewer1.LocalReport.Refresh();

我正在使用一个表格来展示我的数据,使用了数据集。我已经正确地将报表设置给报表查看器。我没有收到任何异常信息。但是报表一直在加载,无法显示。我做错了什么?
如何通过传递参数到查询中来填充数据集,并在报表中使用生成的数据集?
1个回答

14
我刚遇到了这个问题并解决了它。 加载符号一直显示,从未消失。 在我的情况下,问题是我没有处理IsPostBack值。 LocalReport.Refresh()会生成一个回发,如果没有处理,它将不断地进行回发。 这就是我的问题。通过禁用刷新,页面停止了回发。
protected void Page_Load(object sender, EventArgs e)
{
    // Report data source code...
    myReport.LocalReport.Refresh();
}

解决方案:

protected void Page_Load(object sender, EventArgs e)
{
    if(!IsPostBack)
    {
        // Report data source code...
        myReport.LocalReport.Refresh();
    }
}

因此,请确保您正在处理PostBack而不是进入无限循环。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接