Last post Aug 20, 2009 03:17 AM by xequence
Nov 01, 2007 08:27 PM|AlexB1318|LINK
I've got an .RDLC report in an ASP.NET website that I render in a ReportViewer control. The RDLC report is included in teh project, i.e. it is not a SQL Report Server report. It runs fine, i.e. renders data. However, my problem is how to set the value
of the parameters on the report. I've tried the following, but I got an error on the .SetParameters line. And I'm not sure this is the correct approach since the documentation says .SetParameter is only for SQL Report Server reports.
Dim oParams As
New List(Of WebForms.ReportParameter)
I've poured over all of the documentation on Report Services, but I couldn't find anyting on how to set parameter values.
Any ideas anyone?
Nov 06, 2007 05:21 AM|Nai-Dong Jin - MSFT|LINK
From your description, it seems that you want to pass value into your rdlc report, right?
Generally, you can use ReportParameter to feed the parameters to your report. See the following code:
int ParaId = 5;
ReportParameter params = new ReportParameter;
params = new ReportParameter("ParaId", ParaId, false);
And after you've added the code, you also need to define the parameter in the .rdlc file as well. With the .rdlc file open in Visual Studio, go to the Report menu and select Report Parameters.
To be consistent with the code, you should add a parameter named ParaId and then click OK to close the window.
Finally in your .rdlc report designer, you should add a textbox and use expression editor (right-click the textbox and select expression) to set its value =Parameters! ParaId.Value
Jul 02, 2008 09:47 PM|villegates|LINK
I am sure by now we all know that that bit of code is insufficient to run an rdlc with parameters coming from visual basic.net
I have done many things including scouring the internet for solutions and it still fails.
This what I have done:
Firstly in vb.net
Dim params(0) As Microsoft.Reporting.WinForms.ReportParameter
Dim SelectionRange As String
If Trim(ComboBox1.Text = "") Then
SelectionRange = Trim(ChequeDateDateTimePicker.Text & " To " & DateTimePicker1.Text)
params(0) = New Microsoft.Reporting.WinForms.ReportParameter("SelectionRange", SelectionRange, False)
Catch ex As System.Exception
Then in Reports Menu
Set Report Parameter to SelectionRange of Type String
then made it internal values
accept blanks and default value as 'Not Limited'
Then in the RDLC File; the Report Definition
I added a text box to the report and right clicked on it to see additional options.
I selected the Expression and a form popped-up
I then selected parameters->All parameters-> SelectionRange and that parameter was pated to the function box.
You have to type = before it and it will look like this:
I still got an error when trying to do
ERROR: an error occurred while processing the report
But when I comment out that line I get 'Not Limited'
rdlc reportviewer data sources mapped namespace
rdlc reportviewer program-generated
Dec 07, 2008 08:28 PM|vellore.balaji|LINK
your answer is useful...
can u tell how to set the parameter in the Report.rdlc....
Aug 20, 2009 03:17 AM|Xequence|LINK
I am having a similiar issue with these .rdlc report parameters. How do I get them to appear? Granted I can have a dropdownlist with parameters and implement all sorts of logic to show and hide fields to enter a date range in, but I should be able to see
these values before I click "RUN REPORT" button. Here is some of my code, please expand for everyone who has this problems sake.
public partial class Reporting_Reporting : System.Web.UI.Page
ConnectionString _connectionString = new ConnectionString();
Alerting _alert = new Alerting();
DataTable _dtblParts = new DataTable();
DataSet myDataSet = new DataSet();
protected void Page_Load(object sender, EventArgs e)
public DataSet GetDataKeys(SqlDataAdapter dad)
//GridView _gridView = (GridView)sender;
DataTable dtblPartsRequested = new DataTable();
DataColumn keys = new DataColumn;
DataSet myDataSet = new DataSet();
protected void btnRunReport_Click(object sender, EventArgs e)
ReportViewer1.Visible = true;
using (SqlConnection conn = new SqlConnection(_connectionString.GetConnectionString(1)))
SqlDataAdapter dad = new SqlDataAdapter("sp_rpt_MostProblematicItemsV2", conn);
dad.SelectCommand.CommandType = CommandType.StoredProcedure;
myDataSet = GetDataKeys(dad);
ReportDataSource ds = new ReportDataSource("CustomerServiceDataSet_sp_rpt_MostProblematicItemsV2", myDataSet.Tables);
ReportViewer1.LocalReport.ReportPath = "Reporting/Reports/Report1.rdlc";
if (myDataSet.Tables.Rows.Count == 0)
// no data returned
// set param values, not really doing anything except showing up in the report,
// after the fact.
string paraStartDate = Convert.ToDateTime("1/1/2009").ToShortDateString();
string paraEndDate = Convert.ToDateTime("12/1/2009").ToShortDateString();
ReportParameter param = new ReportParameter;
param = new ReportParameter("paraStartDate", paraStartDate, false);
param = new ReportParameter("paraEndDate", paraEndDate, false);
<asp:Button ID="btnRunReport" runat="server" Text="Run Report"
<rsweb:ReportViewer ID="ReportViewer1" runat="server" Font-Names="Verdana"
Font-Size="8pt" Width="600px" ShowParameterPrompts="true"