4

I want to generate a rdlc report by manually populating values to dataset because I send the date as an input to the query. I use the following code to do that

//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();

. I’m using a tablix to show my data using the dataset.I have set the correct report to the report viewer. I don’t get any exceptions. But the report keeps loading and does not show the report. What is it I’m doing wrong.

How can I populate the dataset by passing a parameter to the query, and use the resulting dataset in the report?

4

1 回答 1

11

我刚遇到这个问题并解决了。装载标志一直显示,从未消失。就我而言,问题是我没有处理IsPostBack价值。生成回发,LocalReport.Refresh()如果不处理,它将继续发布和发布。

这是我的问题。通过墙刷新页面一直在做 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 而不是无限循环。

于 2012-08-02T15:56:38.483 回答