Link to home
Start Free TrialLog in
Avatar of tknudsen-qec
tknudsen-qec

asked on

.NET ReportViewer

I'm using a ReportViwer.  It works fine the first time it binds data, but if the criteria (parameters or FilterExpression) change on a postback, the data pulled doesn't change accordingly.

My changing paramaters are datevariable1 and datevariable2, which change depending on user input.

Rather than keep smashing my forehead off my desk I figured I might as well see if any EXPERTS had a notion what I'm doing wrong.

Please assist!


ReportViewer ReportViewer1 = new ReportViewer();
ReportViewer1.LocalReport.ReportPath = "Report1.rdlc";

ObjectDataSource ODS = new ObjectDataSource("GraphTest.ValuesByDateDataSetTableAdapters.vValuesByDateTableAdapter", "GetDataByDateRange");
ReportDataSource RDS = new ReportDataSource("ValuesByDateDataSet_vValuesByDate", ODS);

	
ODS.SelectParameters.Add("Start", datevariable1.ToString("d"));
ODS.SelectParameters.Add("End", datevariable2.ToString("d"));

ReportViewer1.LocalReport.DataSources.Clear();
ReportViewer1.LocalReport.DataSources.Add(RDS);

PlaceHolder1.Controls.Add(ReportViewer1);

Open in new window

Avatar of Alfred A.
Alfred A.
Flag of Australia image

Try to add this after your code snippet:

ReportViewer1.LocalReport.Refresh()
you close the report viewer after displaying the report and load as a fresh viewer for the filtered data.
ASKER CERTIFIED SOLUTION
Avatar of tknudsen-qec
tknudsen-qec

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of tknudsen-qec
tknudsen-qec

ASKER

samsymon,
Thanks kindly for your reply.  I'm not clear on whether your comment was a suggestion on what I'm doing wrong or what I could do right, sorry :(

I seem to have found a workaround solution for now however.  

Thanks again.
Try the following function
ReportViewer1.RefreshReport();
Hi greatsubash,

Thanks for your reply.  For the webforms version of the ReportViewer class, RefreshReport is an event, not a method, and I don't see how I would handle it to fix this.

Thanks