I have added two text boxes for the date range in the report. To fill the values in the text boxes, I set parameters to the text boxes.
Now the date range is coming from a form named DateRange having two DateTimePickers.
How to set the value of the text boxes in rdlc equal to these DataTimePickers?
➤ Open RDLC, Go to “Report Data” window. ➤ Find “Parameter” and right click on it. ➤ Click on “Add Parameter…” option. ➤ This will show “Report Parameter Properties” screen. ➤ Type Parameter name inside “Name” Box and set Data Type as ' Text' from "Data Type:" box. Then press “OK” button.
Design the RDLC Report At first we need to design or create the rdlc report. Suppose we are using a Stored Procedure (SP) and it has only one parameter. It’s name is “Parameter1” and it’s data type is integer. Add Parameter to the rdlc Report From the Report Data panel right click on Parameters and select Add Parameters..
The Parameters will be passed to RDLC Report using object of the ReportParameter class in ASP.Net using C# and VB.Net. This is applicable to all ReportViewer controls belonging to all different Visual Studio versions such as 2010, 2012, 2013, 2015, 2017 and 2019. 1. I have already added a blank RDLC Report and an Image to the Solution folder. 2.
From the Report Data panel right click on Parameters and select Add Parameters.. From the Report Parameter Properties window set the parameter name, data types and click Ok. Remember that the parameter name should be as like as the parameter name used in Stored Procedure (SP). We can also set other options like available values, default values etc.
You can set parameter value like this.
DateTime dtStartDate = dateTimePicker1.Value;
DateTime dtEndDate = dateTimePicker2.Value;
ReportParameter[] params = new ReportParameter[2];
params[0] = new ReportParameter("StartDate", dtStartDate, false);
params[1] = new ReportParameter("EndDate", dtEndDate, false);
this.ReportViewer1.ServerReport.SetParameters(params);
Passing Parameters to RDLC
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With