Search code examples
c#winformsreporting-servicesreporterror-reporting

Report using RDLC can't load dataset


I am trying to make an report using RDLC file .I am following this link :

http://www.mindstick.com/Articles/13169999-ef3b-496c-b502-caef973c3bb2/?Using%20ReportViewer%20in%20WinForms%20C

So i create a RDLC file an import my tax object to this report my tax ubject has a structure like this :

public partial class Tax
    {
        public Tax()
        {
            this.Innovices = new HashSet<Inovice>();
        }
        [DisplayName("شناسه")]
        public int Id { get; set; }
        [DisplayName("عوارض شهرداری")]
        public Nullable<double> MunicipalTax { get; set; }
        [DisplayName("مالیات بر ارزش افزوده")]
        public Nullable<double> AdditionalTax { get; set; }
        [DisplayName("سال مالی")]
        public string Year { get; set; }

        public virtual ICollection<Inovice> Innovices { get; set; }
    }

Here you can see binding object to my report :

enter image description here

I put a reportviewer in y form and i write this code in `formload

 private void Form1_Load(object sender, EventArgs e)
        {
            InvoiceRepository.TaxRepository obj = new TaxRepository();
            List<InnoviceDomainClass.Tax> list = obj.GetAll().ToList();

            reportViewer1.LocalReport.DataSources.Clear(); //clear report
            reportViewer1.LocalReport.ReportEmbeddedResource = "Factor169.Report.Report1.rdlc";
                // bind reportviewer with .rdlc

            Microsoft.Reporting.WinForms.ReportDataSource dataset =
                new Microsoft.Reporting.WinForms.ReportDataSource("Dataset1", list); // set the datasource
            reportViewer1.LocalReport.DataSources.Add(dataset);
            dataset.Value = list;

            reportViewer1.LocalReport.Refresh();
            reportViewer1.RefreshReport(); // refresh report
        }`

But after executing the result is like this :why ? enter image description here


Solution

  • Microsoft.Reporting.WinForms.ReportDataSource dataset =
                new Microsoft.Reporting.WinForms.ReportDataSource("Dataset1", list); 
    

    Should be DataSet1

    ReportDataSource("DataSet1", list); //The "s"
    

    The name of the report datasource must be the same as the dataset in the report.