Reputation: 2557
I have a winform with a datefield. When a user selects a date and submits, a reportviewer on the page takes the date as a parameter through the tableadapter and shows the report.
What I need is a way to print the user selected date on the report.
Can someone show me how to pass a value from the winform to the rdlc file and make it print on the report itself?
I assume I would use a report parameter, but I can't seem to find any good documentation on how to accomplish this. thanks.
Upvotes: 2
Views: 1381
Reputation: 7451
You can do something like this:
IList<ReportParameter> parameters = new List<ReportParameter>();
parameters.Add(new ReportParameter("MyDate", "1/1/2011"));
viewer.LocalReport.SetParameters(parameters);
viewer.RefreshReport();
The name of the parameter (MyDate above) must matches the name with wich you have defined the parameter in the report designer.
Upvotes: 0
Reputation: 29497
Check Report Parameters (ReportViewer Controls) and one suggestion, visit MSDN when you need some references, because if you do it you will learn more and better. ;)
Upvotes: 1