我想通过手动将值填充到数据集来生成 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();
. 我正在使用 Tablix 来使用数据集显示我的数据。我已将正确的报告设置为报告查看器。 我没有得到任何异常(exception)。但是报告一直在加载并且不显示报告。我做错了什么。
如何通过将参数传递给查询来填充数据集,并在报告中使用生成的数据集?
最佳答案
我刚遇到这个问题并解决了它。
加载标志一直显示并且从未消失。
在我的例子中,问题是我没有处理 IsPostBack
值。
LocalReport.Refresh()
生成一个回发,如果不处理,它会一直发布和发布。
这是我的问题。通过墙 Refrеsh 页面继续做 PostBacks
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 而不是无限循环。
关于c# - RDLC 报告不断加载而不显示数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11049917/