troubleshooting Question

Displaying list data in a Microsoft Report Viewer control

Avatar of RedneckWonderland
RedneckWonderland asked on
.NET ProgrammingVisual Basic.NETSSRS
3 Comments1 Solution1829 ViewsLast Modified:
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,

Bill
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
        col.Add(mReportData)

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

        rpv.RefreshReport()

        scSplitter.Panel2.Controls.Add(rpv)

        If Not rvReportViewer Is Nothing Then
            scSplitter.Panel2.Controls.Remove(rvReportViewer)
            rvReportViewer = Nothing
        End If

        rvReportViewer = rpv

        rvReportViewer.RefreshReport()
    End Sub
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 3 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros