Sorting report data in ReportViewer using BindingSource
I am trying to get the ReportViewer to display data from a BindingSource (VB.Net Winforms).
I built a report on a basic dataset. Then I configured the datasource instance to be the BindingSource. I thought this would apply sorting, filtering, etc. But it looks like the data is coming from the dataset instead of the BindingSource.
I suspect I am missing something simple.
Update: Or maybe it's not that easy - I posted this a few days ago and still no one knows the answer! Maybe I am trying to do something that cannot be done?
0
source to share
2 answers
Here is the solution I used. You put data from the BindingSource into a DataTable and then use the DataTable report.
ReportViewer1.Reset()
Dim dt As DataTable
dt = DirectCast(Form1.ProgActnBindingSource.Current, DataRowView).DataView.ToTable
Dim rs = New ReportDataSource
rs.Name = "name"
rs.Value = dt
ReportViewer1.ProcessingMode = ProcessingMode.Local
ReportViewer1.LocalReport.DataSources.Clear()
ReportViewer1.LocalReport.DataSources.Add(rs)
ReportViewer1.LocalReport.ReportEmbeddedResource = "projectname.Report1.rdlc"
Me.ReportViewer1.RefreshReport()
0
source to share