• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1553
  • Last Modified:

Displaying list data in a Microsoft Report Viewer control

I'm using Visual Studio 2008 with Visual Basic .Net web forms to display a local report.  I am not using SSRS.  I am not using Crystal Reports but rather the Microsoft Report Viewer.

I have a series of business data objects which source their data from an xml file.  I am attempting to use these objects to display this data in a report.

It seems to work fine if I want to display data at the top level of the hierarchy of data objects, it also works if I want to display an individual record from one of the child collections ie. =Fields!MyCollection.Value(2)

However, I can't figure out how to populate a graph/chart or table with list data based on the same collections...
ie: =Fields!MyCollection.Value

I have attempted to use basic arrays for the collections and also generic collection objects to no avail.

When attempting to populate a graph no data populates it.  When I attempt to populate a table it simply displays the text "#Error"

I have also attempted to use a datatable containing the required data but the report won't allow me to drag the data table property from my datasource onto the report for some reason.  I can't see how I could use a datatabe as my source object.

See code snipet for how I am setting up the report data.  A couple of things in this method might look strange:
1) I am destroying and replacing the dataview control on the form because the form.  The form is set up so the user can choose a report from a treeview from a left pane and it displays in the right pane.  There seems to be a bug in the report viewer where it will only display the first report selected.  This is my attempt at a work-around.

2) Even though my potentialproperty object is a singular object, I am loading it into a collection so that the object I am parsing implements iEnumerable.  Not sure if this is the best way of doing things but it seems to work.

Thanks in advance,

Private Sub LoadReport(ByVal strReportPath As String)
        Dim rpv As Microsoft.Reporting.WinForms.ReportViewer

        rpv = New Microsoft.Reporting.WinForms.ReportViewer()

        rpv.ProcessingMode = Microsoft.Reporting.WinForms.ProcessingMode.Local

        rpv.LocalReport.ReportPath = strReportPath

        Dim col As Collection = New Collection

        rpv.LocalReport.DataSources.Add(New Microsoft.Reporting.WinForms.ReportDataSource("DataLayer_PotentialProperty", col))



        If Not rvReportViewer Is Nothing Then
            rvReportViewer = Nothing
        End If

        rvReportViewer = rpv

    End Sub

Open in new window

  • 2
1 Solution
RedneckWonderlandAuthor Commented:

I already found that site.  It got me to the point I am at now but is no help with the problems I am currently experiencing
RedneckWonderlandAuthor Commented:
I've just figured out how to create a strongly written dataset which enables me to use a dataset to acheive what I want to achieve here.  It isn't ideal but it's a solution.

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now