Posted 2 December 2017, 9:50 am EST
Hi!
I need to provide datatable to DataSet in run time to Page report.
Unfortunately the model does not work. Event LocateDataSource does not fire.
I need help.
DataSource and DataSet are declared in my document.
The code:
OStrRepordtDefinition = “<Report xmlns…”
Dim OCPageReporter As New CPageReporter(OMyWebViewer1, StrRepordtDefinition, ODataTablePrintoni01)
Private Class CPageReporter
Dim WithEvents OPageReportAtRunTime As GrapeCity.ActiveReports.Document.PageDocument
Dim ODataTable As DataTable
Public Sub New(ByRef InOMyWebViewer1 As MyWebViewer1, InOStrReportDefinition As String, InOdataTable As DataTable)
ODataTable = InOdataTable
'Create a report definition that loads an existing report. Dim readerPageReport As TextReader = New StringReader(InOStrReportDefinition) Dim definition As New GrapeCity.ActiveReports.PageReport(readerPageReport) 'Dim ODataSource01 As GrapeCity.ActiveReports.PageReportModel.DataSource = definition.Report.DataSources(0) 'Load the report definition into a new page document. OPageReportAtRunTime = New GrapeCity.ActiveReports.Document.PageDocument(definition) AddHandler OPageReportAtRunTime.LocateDataSource, AddressOf OPageReportAtRunTime_LocateDataSource 'Attach the runtime to an event. This line of code creates the event shell below. 'definition.Document.DataSourceLocator.LocateDataSource("DataSource01", "DataSet01ZaDenia", definition.Report) InOMyWebViewer1.Report = OPageReportAtRunTime End Sub 'ActiveReports raises this event when it cannot locate a report's data source in the usual ways. Private Sub OPageReportAtRunTime_LocateDataSource(ByVal sender As Object, ByVal args As GrapeCity.ActiveReports.LocateDataSourceEventArgs) Handles OPageReportAtRunTime.LocateDataSource Beep() 'Dim dl = New DataLayer 'args.Data = dl.DataSetData.Tables("Products") args.Data = ODataTable 'args. End Sub End Class