ty812
ty812

Reputation: 3323

Connect a customly created dataset to a report

I have created a dataset with a C# class in Visual Studio 2012. I now want to create a report using VS Reporting. How do I get to bind them? How can I use the dataset definition to create a report in the report designer?

I have created a report based on the xsd and a reportviewer in a WinForm. What I have is this:

  private void Form9_Load(object sender, EventArgs e)
    {

        // listGeraete fetches all the data I need and does some calculations
        listGeraete gList = new listGeraete();
        gList.addById(200001);
        gList.addById(201000);

        // This creates a DataSet with all the data I need.
        // The dataset is well-formed and uses the same dataset definition
        // that the report uses.
        dsGeraete d = gList.getDataSet();


        // Something has to happen here to bind the dataSet to the reportViewer



        this.reportViewer1.RefreshReport();


    }

I tried googling, but the results all come back to binding an sql server to a dataset - that's not what I need...

Any help would be appreciated.

Upvotes: 0

Views: 355

Answers (2)

CGross
CGross

Reputation: 513

You need to set the dataset as a datasource then refresh. Some of the syntax may be different for a winforms control, but this is what it is for an asp.net page.

        this.reportViewer1.Reset();
        this.reportViewer1.ProcessingMode = ProcessingMode.Local;
        this.reportViewer1.LocalReport.DataSources.Clear();
        this.reportViewer1.LocalReport.DataSources.Add(dataset);
        this.reportViewer1.LocalReport.Refresh();

Upvotes: 1

acciocode
acciocode

Reputation: 26

You need to fill the table adapter. See if this video helps you.

Upvotes: 1

Related Questions