I have an existing class structure in place and want / should use it as a data source for a series of reports using vb and 2005 (although we are almost ready to move on to 2010, so if this solves this bad move today!)
Using the getreportviewer sample for nested objects, ive added a reportmanager class representing the getdata method, which was populated with all my data and returned a list (of an object). the data is and is corrected at the data binding point, I can add and refer to top-level properties, however it doesn’t matter what syntax I'm trying to use, I can not refer to fields in nested classes / lists. I get various messages from "#Error" in the output field to nothing so as not to compile.
my class structure is roughly in short form:
Assembly0
Class ReportManager
TheData as List(Of Object)
New() 'that populates TheData from the class structure below
GetData() as List(of Object)
Assembly1
Class Test
aProperty1 as String
aProperty2 as Int
aProperty3 as String
aProperty4 as String
aProperty4 as List(of aType1)
Assembly2
Class AaType1
aProperty1 as String
aProperty2 as Int
aProperty3 as String
aProperty4 as String
aProperty4 as List(of aType2)
aProperty4 as List(of aType3)
aProperty4 as String
Assembly3
Class aType2
aProperty1 as Boolean
aProperty1 as String
you get the idea
and so on.....
in my main application
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' Create an instance of our ReportManager Class
Try
' trust assemblies used in get data
ReportViewer1.LocalReport.ExecuteReportInCurrentAppDomain(Assembly.GetExecutingAssembly().Evidence)
ReportViewer1.LocalReport.AddTrustedCodeModuleInCurrentAppDomain("assy1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1234")
ReportViewer1.LocalReport.AddTrustedCodeModuleInCurrentAppDomain("assy2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1234")
' etc through ALL dependant assemblies
' create datamanager, that will populate its TheData property
Dim reportMan As Data.Reporting.Manager = New Data.Reporting.Manager(18) ' test id sent
' this is the method from the gotreportviewer sample, which only allows you to reference top level properties, regardless of syntax used. i.e. =Fields!Prop.Value.SubProp
' doesnt work
'ReportViewer1.LocalReport.DataSources.Add(New ReportDataSource("DummyDataSource", reportMan.GetData))
'Me.ReportingDataBindingSource.DataSource = reportMan.GetData
' this is the only method i have found that allows me to reference an objects nested property and its fields.....?
Data = reportMan.GetData()
Me.ReportViewer1.ProcessingMode = Microsoft.Reporting.WinForms.ProcessingMode.Local
Me.ReportViewer1.LocalReport.DataSources.Add(New ReportDataSource("Data_Reporting_ReportingData", Data))
' fortnatley there is only ever one test in the list, HOWEVER there will be 4 specimens and n stages below that and so on..
Dim SpecimenData As SpecimenList = Data(0).Specimens
Me.ReportViewer1.LocalReport.DataSources.Add(New ReportDataSource("Tests_Specimen", SpecimenData))
' so this method is no good either. currently only a test its just returning the first specimen.
'Dim StageData As Tests.Stages = Data(0).Specimens(0).Stages
'Me.ReportViewer1.LocalReport.DataSources.Add(New ReportDataSource("Tests_Specimen", SpecimenData))
' render report
Me.ReportViewer1.RefreshReport()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Corrections I found online / googling:
You should add "ExecuteReportInCurrentAppDomain", made no difference.
You should add Assembly: AllowPartiallyTrustedCallers () in AssemblyInfo.vb, there is no difference.
, ,
, ""
( ).
= Fields! Property.Value.SubProperty DOESNT! , .
' rdlc -
= Sum (Fields! TestVersion.Value, "Data_Reporting_ReportingData" )
', ,
= First (Fields! Index.Value, "Tests_Specimen" )
',
= First (, .Value.Index, "Data_Reporting_ReportingData" )
= Fields! Specimens.Value.Index
= Fields! Specimens.Value.Index.Value
, , , -
Dim SpecimenData As Tests.SpecimenList = Data (0). ? id .
, , , / , , , , .
- , ? , . / .
ive ! im , , .
, - , ?
? ?
...
Matma