Search code examples
c#.netwinformsreporting-servicesrdlc

RDLC report table not populate data from dataset


I am creating an app that prints invoices through Microsoft RDLC report.The report showing some data but the tablix is not showing the values which i provide from dataset.Please see my code below and try to solve my problem.

private void InvoiceButton_Click(object sender, EventArgs e)
        {

            Parameters p = new Parameters();
            List<Parameters> lst = new List<Parameters>();
            p.date = CurrentDateTimePicker.Text;
            p.CustomerName = CustomerTextBox.Text;


            if (CartDataGridView.Rows.Count != 0)
            {
                for (int i = 0; i < CartDataGridView.Rows.Count-1; i++)
                {
                    lst.Add(new Parameters
                    {
                        
                        ItemName = CartDataGridView.Rows[i].Cells[1].Value.ToString(),
                        Price = CartDataGridView.Rows[i].Cells[2].Value.ToString(),
                        Quantity = CartDataGridView.Rows[i].Cells[3].Value.ToString(),
                        Company = CartDataGridView.Rows[i].Cells[4].Value.ToString(),
                        ExpiryDate = CartDataGridView.Rows[i].Cells[5].Value.ToString(),
                        Total = CartDataGridView.Rows[i].Cells[7].Value.ToString()
                       // Subtotal = (Convert.ToInt32(CartDataGridView.Rows[i].Cells[7].Value))
                    });
                }
            }

            InvoiceForm f = new InvoiceForm();
            ReportDataSource rd = new ReportDataSource("MyDataSet");
            
            rd.Value = lst;
            f.reportViewer1.LocalReport.ReportEmbeddedResource = "CPMSTestPhase.InvoiceReport.rdlc";
            f.reportViewer1.LocalReport.DataSources.Add(rd);

            ReportParameter[] rptparam = new ReportParameter[]
         {
                new ReportParameter("Date",p.date),
                new ReportParameter("CustomerName",p.CustomerName),
              //  new ReportParameter("Subtotal",p.Subtotal.ToString()),

         };
            f.reportViewer1.LocalReport.SetParameters(rptparam);


            f.reportViewer1.RefreshReport();
            f.ShowDialog();
        }
    }ere

enter image description here

enter image description here

I try all solutions available on youtube but did not work.


Solution

  • I myself figured out the issue. The issue is with the order of dataset fields and my parameters class properties. They should be the same.