Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RDLC report keeps loading without showing data

Tags:

c#

rdlc

reporting

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?

like image 782
user1450810 Avatar asked Dec 20 '22 20:12

user1450810


1 Answers

I just had this problem and solved it. The loading sign kept showing and never dissapearing. In my case the problem was that I wasn't handling the IsPostBack value. The LocalReport.Refresh() generates a postback and if not handled, it will keep posting and posting.

This was my problem. By walling Refrеsh the page kept doing PostBacks

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

SOLUTION:

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

So, check that you are handling the PostBack and not getting an infinite loop.

like image 174
Juanu Avatar answered Dec 24 '22 01:12

Juanu