none
ASP.NET Report Viewer - Bind a BindingList<> RRS feed

  • Question

  • I added a Report Viewer control to a ASP.NET WebForm App and want to bind a collection of data to the datasource. I previously created a Windows Form Application with a Report Viewer control and was able to do so, however with this web app, it seems as if the datasource can only be SQL. I attempted to add the .RDLC file from my previous Windows Form Application to the new web app, in which it loads correctly, however I am stumped on how I can add something such as BindingList<> to the datasource. Any suggestions?

    Gerneio

    Wednesday, July 1, 2015 4:35 PM

Answers

  • I beleive I figured out a potential solution using the following code:

    ReportDataSource rds = new ReportDataSource("DataSet1", CollectionOfData);
    ReportViewer1.LocalReport.DataSources.Add(rds);
    ReportViewer1.DataBind(); // This line of code might be unnecessary
    ReportViewer1.LocalReport.Refresh(); // This line of code might be unnecessary

    The only other issue was attempting to put the data source itself in the Report.RDLC file so I can get my DataSet, but I was able to get it put together with a bit of odd trickery. It's a good thing to note that the name of the data source in the RDLC file should be the same as the name given for the ReportDataSource as shown in the code above ("DataSet1").

    One thing I wasn't able to figure out is how to accomplish this in the .ASPX file under the ReportViewer control. But I'm sure there's a way, I just haven't done enough digging yet.

    Gerneio

    • Marked as answer by Gerneio Sunday, July 12, 2015 7:02 PM
    Friday, July 3, 2015 6:27 PM