How to pass a Datatable to Reportviewer?

Asked

Viewed 163 times

0

I receive the database query in a Datatable, I need to pass the datatable to a tablix in reportviewer by code, but when I run the tablix returns blank, I searched in several places and did not find an agile method to do this, follow the code...

private void frmRel_Load(object sender, EventArgs e)
    {
        this.report.RefreshReport();

        DataTable dt = RelatoriosModel.PesquisaTodos(); // RETORNA A TABELA DA CONSULTA NO SERVIDOR

        ReportDataSource reportDataSource = new ReportDataSource();

        this.report.LocalReport.ReportEmbeddedResource = "CifalApp.Logistica.Relatorios.Relatorio.rdlc";

        reportDataSource.Name = "DataSet1";
        reportDataSource.Value = dt;

        this.report.LocalReport.DataSources.Add(reportDataSource);
        this.report.RefreshReport();
    }

Imagem do RDLC

  • But this tablix is pulling your data from "Dataset1"?

  • There is nothing in Dataset1

  • And where tablix is pulling the data from to render the report then?]

  • That’s the question, I don’t know how to make tablix pull data from datatable, or pass datatable pro tablix, I’m trying to do this without using a typed Dataset, that way above was just for testing

  • Then your job starts in assembling the report first and then popular the dataset to display your data. What good is it to send a data set to it if it has no structure waiting for that load?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.