Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set parameter values in RDLC

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?

like image 895
DhavalR Avatar asked Jan 17 '15 06:01

DhavalR


People also ask

How to add new parameter in RDLC?

➤ 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.

How to design and create RDLC report?

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..

How to pass parameters to RDLC report in ReportViewer?

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.

How to add parameters to a report?

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.


1 Answers

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

like image 65
Shell Avatar answered Oct 08 '22 07:10

Shell