ColinMillard
New member
- Joined
- Apr 10, 2008
- Messages
- 2
- Programming Experience
- 3-5
Hi All,
I am using one reportviewer on a single form and want to dynamically load a report based on different criteria, eg. if 1 is selected then display report 1, if report 2 selected then display report 2 etc etc.
I built a dataset using the wizard, then use this dataset to add the columns onto the report.
At Runtime I populate a dataset dynamically in code (returning the same data as the original dataset), and then would like to load both the dataset and the report into the report viewer.
Here is a sample of the code. Its quite basic, however I am having issues with binding the dataset to the reportviewer etc.
-Sample Code-
Any help would be appreicated
C
I am using one reportviewer on a single form and want to dynamically load a report based on different criteria, eg. if 1 is selected then display report 1, if report 2 selected then display report 2 etc etc.
I built a dataset using the wizard, then use this dataset to add the columns onto the report.
At Runtime I populate a dataset dynamically in code (returning the same data as the original dataset), and then would like to load both the dataset and the report into the report viewer.
Here is a sample of the code. Its quite basic, however I am having issues with binding the dataset to the reportviewer etc.
-Sample Code-
VB.NET:
Private Sub ReportViewer_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles ReportViewer.Load
Dim dtLeague As New DataSet
Try
'---------------------------------------------------
' Display the Desired buttons
ReportViewer.ProcessingMode = ProcessingMode.Local
ReportViewer.ShowExportButton = True
ReportViewer.ShowPrintButton = True
ReportViewer.ShowToolBar = True
ReportViewer.ShowZoomControl = True
'-----------------------------------------------------
' Get the information to be displayed in the report
dtLeague = GetData.GetFullLeagueDetails("00002")
'-----------------------------------------------------
' Checking - this returns 1 row (correct)
Dim rowcount As Integer = dtLeague.Tables(0).Rows.Count
'-----------------------------------------------------
' Give the report a Title
ReportViewer.LocalReport.DisplayName = "ELS: League Report"
'-----------------------------------------------------
' load the required report
ReportViewer.LocalReport.ReportPath = "Reports\rLeagueDetails.rdlc"
'-----------------------------------------------------
' Create a Datasource
' Here, (I beleve the problems lie)
Dim LocalReportDataSource As ReportDataSource = New ReportDataSource
LocalReportDataSource.Name = "ELSLeagueDetails"
LocalReportDataSource.Value = dtLeague.Tables(0)
ReportViewer.LocalReport.DataSources.Add(LocalReportDataSource)
ReportViewer.LocalReport.Refresh()
'-----------------------------------------------------
Catch ex As Exception
MsgBox("Report Error", MsgBoxStyle.Critical)
Finally
End Try
End Sub
C