Hello Steve,
Welcome to the MSDN newsgroup.
From your description, I understand you're using the .NET 2.0's winform
ReportViewer control to display some client report(based on rdlc file) in
your winform application. However, since you have mulitple such rdlc
template and various datasources, you're wondering how dynamically change
the reportViewer's datasource(disp layed data) and refresh it, correct? If
anything I've missed, please feel free to let me know.
Based on my research, the winform reportviewer control does support
programmatic datasource configuration(b oth server report or local report)
through its certain properties. And to dynamically update the report data,
you can:
1. For server report, you can simply change the "ServerRepo rt" property's
certain sub properties and refresh the reportviewre. e.g.
=============
Private Sub btnTest_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles btnTest.Click
Me.ReportViewer 1.ProcessingMod e =
Microsoft.Repor ting.WinForms.P rocessingMode.R emote
Me.ReportViewer 1.ServerReport. ReportServerUrl = New
Uri("http://localhost/ReportServer/")
Me.ReportViewer 1.ServerReport. ReportPath =
"/ReportProj1/GroupReport"
Me.ReportViewer 1.RefreshReport ()
End Sub
===============
2. As for LocalReport, which rely on a rdlc template (on file system or
embeded in assembly resource), it is more complex to rebind the datasource
comparing to ServerReport model. Actually, we need to reset the
reportViewer first, and then add the new datasoruce (ReportDataSour ce)
needed, and change the LocalReport's reportPath(or embededResource name).
After that, still refresh the ReportViewer control to see the update. e.g.
=============== ==========
=============== ===========
Private Sub btnClientTest_C lick(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles btnClientTest.C lick
Me.ReportViewer 1.Reset()
Me.ReportViewer 1.ProcessingMod e =
Microsoft.Repor ting.WinForms.P rocessingMode.L ocal
Dim newds As New
Microsoft.Repor ting.WinForms.R eportDataSource ("NorthwindData Set1_Region")
newds.Value = Me.RegionBindin gSource
Me.ReportViewer 1.LocalReport.D ataSources.Add( newds)
Me.ReportViewer 1.LocalReport.R eportEmbeddedRe source =
"ClientReportAp p.Report2.rdlc"
Me.ReportViewer 1.RefreshReport ()
End Sub
=============== =========
In the above example, the "RegionBindingS ource" is a pregenerated winform
BindingSource(c onfigured throug DataSet/DataAdapter pairt) in design-time.
Hope this helps. If there is any other problems you met, please feel free
to post here.
Regards,
Steven Cheng
Microsoft Online Community Support
=============== =============== =============== =====
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.
Get Secure!
www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)