Reputation: 184
I am trying to make an report using RDLC
file .I am following this link :
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 :
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 ?
Upvotes: 2
Views: 2267
Reputation: 4784
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.
Upvotes: 2