This is a migrated thread and some comments may be shown as answers.

Report parameters in CS are blank

3 Answers 181 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Virgil
Top achievements
Rank 1
Virgil asked on 17 Jul 2017, 12:43 AM

Hello,

I have a report that has two parameters.  When accessing the report parameters from the report CS file, the parameters are in the collection, but the values are blank.  Any help would be much appreciated.

 

Thanks,
Virgil

 

ReportViewer.aspx

1.<form id="form1" runat="server">
2.    <div>
3.        <telerik:ReportViewer ID="ReportViewer1" runat="server">
4.        </telerik:ReportViewer>
5.    </div>
6.</form>

 

ReportViewer.aspx.cs

01.protected void Page_Load(object sender, EventArgs e)
02.{
03.    int tableId = int.Parse(Request["tableId"]);
04.    int reportType = int.Parse(Request["reportType"]);
05. 
06.    string typeName = typeof(BG0001).AssemblyQualifiedName;
07. 
08.    var reportSource = new Telerik.ReportViewer.Html5.WebForms.ReportSource();
09.    reportSource.Identifier = typeName;
10.    reportSource.IdentifierType = Telerik.ReportViewer.Html5.WebForms.IdentifierType.TypeReportSource;
11.    reportSource.Parameters.Add("TableId", tableId);
12.    reportSource.Parameters.Add("ReportType", reportType);
13.     
14.    this.ReportViewer1.ReportSource = reportSource;
15.}

The generated markup
<input id="ReportViewer1_hidden" name="ReportViewer1_hidden" type="hidden" value="{"documentMapVisible":true,"parametersAreaVisible":true,"scale":1,"scaleMode":"SPECIFIC","viewMode":"INTERACTIVE","printMode":"AUTO_SELECT","reportSource":{"report":"TestReports.Reports.BG0001, TestReports.Reports, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null","parameters":{"TableId":38,"ReportType":3}},"pageNumber":1}">

 

The code inside the BG0001 report

01.public BG0001()
02.{
03.    //
04.    // Required for telerik Reporting designer support
05.    //
06.    InitializeComponent();
07. 
08.    this.ProcessReportParams();
09. 
10.}
11. 
12.protected void ProcessReportParams()
13.{
14.    this.teamId = int.Parse(this.ReportParameters["TableId"].Value.ToString());
15.    this.reportType = int.Parse(this.ReportParameters["ReportType"].Value.ToString());
16.}

 

Intermediate window test of parameter values

01.?this.ReportParameters["TableId"]
02.{Telerik.Reporting.ReportParameter}
03.    AllowBlank: false
04.    AllowNull: false
05.    AutoRefresh: false
06.    AvailableValues: {(none)}
07.    Mergeable: true
08.    MultiValue: false
09.    Name: "TableId"
10.    Text: ""
11.    Type: Integer
12.    Value: ""
13.    Visible: true

 

 

 

3 Answers, 1 is accepted

Sort by
0
Accepted
Stef
Telerik team
answered on 19 Jul 2017, 01:32 PM
Hello Virgil,

The parameters values are submitted correctly and the values are available in expressions and events in the report. The submitted values will not be available in the report's constructor.


If you need the values for getting data, please use the approaches from:
If you need further help, please elaborate on the usage of parameters in the report.

Regards,
Stef
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Virgil
Top achievements
Rank 1
answered on 19 Jul 2017, 11:33 PM

Hi Stef,

Thank you for the feedback.  Taking your suggestion I created a NeedDataSource event.  My issue is that it does not fire  :(.  Am I missing something to get it to fire?

 

1.private void BG0001_NeedDataSource(object sender, EventArgs e)
2.{
3.    Telerik.Reporting.Processing.Report processingReport = (Telerik.Reporting.Processing.Report)sender;
4. 
5.    this.teamId = int.Parse(processingReport.Parameters["TableId"].Value.ToString());
6.    this.reportType = int.Parse(processingReport.Parameters["ReportType"].Value.ToString());
7.}
0
Accepted
Virgil
Top achievements
Rank 1
answered on 19 Jul 2017, 11:48 PM

Got it.  Added "this.DataSource = null;" to the constructor.

 

Thanks for assist  :)

Tags
General Discussions
Asked by
Virgil
Top achievements
Rank 1
Answers by
Stef
Telerik team
Virgil
Top achievements
Rank 1
Share this question
or