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

Passing Query String Values into a TRDX report template

3 Answers 34 Views
Report Designer (standalone)
This is a migrated thread and some comments may be shown as answers.
thelostleaf
Top achievements
Rank 2
thelostleaf asked on 16 Mar 2021, 08:04 PM

Hi, 

I've poured over numerous documents for many hours and can not find a resolution.

Inside the TRDX file there is a SQL statement, it is hard coded to 'WHERE ProjectId = 1234'

When I create a report parameter and add to the UriReportSource, it never works. 

 

The SqlDataSource has this parameter

<Parameters>
        <SqlDataSourceParameter DbType="Int32" Name="@ProjectId" />
</Parameters>

At the bottom of the .trdx file, it has this parameter.

<ReportParameters>
    <ReportParameter Name="ProjectId" Type="Integer" Visible="True">
      <Value>
        <String>= Parameters.ProjectId.Value</String>
      </Value>
    </ReportParameter>
  </ReportParameters>

 

C# on reporting view page, 

    Telerik.Reporting.Parameter p = new Telerik.Reporting.Parameter();
    p.Name = "ProjectId";
    p.Value = 1234;
    uriReportSource.Parameters.Add(p);
    rpvCustom.ReportSource = uriReportSource;

Any help is greatly appreciated, my client is creating these reports with the standalone designer, but we can only get results with hard coding.

 

 

3 Answers, 1 is accepted

Sort by
0
thelostleaf
Top achievements
Rank 2
answered on 16 Mar 2021, 08:06 PM

A quick note, I tried changing the SQL statement in the trdx file to 

'WHERE ProjectId = @ProjectId' 

And still no results.

0
Dimitar
Telerik team
answered on 19 Mar 2021, 03:08 PM

Hello Eric,

The way your report parameter seems to be set seems incorrect. For some reason, you are trying to set its value to be of that parameter's value. 

I made a sample report with the standalone designer using a SQL parameter and exported it to .trdx file.

The following is how a report parameter can look for example in the .trdx file:

 <ReportParameters>
    <ReportParameter Name="Parameter1" Type="Integer" Visible="True" AutoRefresh="True">
      <Value>
        <String>14</String>
      </Value>
    </ReportParameter>
  </ReportParameters>

It simply has some default value that I have set. Then for the SQL parameter:

  <SqlDataSource QueryDesignerState="null" ParameterValues="{&quot;@ID&quot;:&quot;5&quot;}" ConnectionString="Telerik.Reporting.Examples.CSharp.Properties.Settings.TelerikConnectionString" SelectCommand="SELECT&#xD;&#xA;[HumanResources].[vEmployee].[EmployeeID] ,&#xD;&#xA;[HumanResources].[vEmployee].[FirstName],&#xD;&#xA;[HumanResources].[vEmployee].[LastName],&#xD;&#xA;[HumanResources].[vEmployee].[JobTitle],&#xD;&#xA;[HumanResources].[vEmployee].[Phone]&#xD;&#xA;FROM [HumanResources].[vEmployee]&#xD;&#xA;WHERE [HumanResources].[vEmployee].[EmployeeID] &lt;= @ID&#xD;&#xA;ORDER BY 1 ASC" Name="sqlDataSource1">
      <Parameters>
        <SqlDataSourceParameter DbType="Int32" Name="@ID">
          <Value>
            <String>= Parameters.Parameter1.Value</String>
          </Value>
        </SqlDataSourceParameter>
      </Parameters>
    </SqlDataSource>

This is where you can set the SQL parameter to use the value of the report parameter.

For doing this process through code, you can have a look at our - Using Parameters with the SqlDataSource component article.

I have also attached a sample report and a short video that showcases how you can do this through the Standalone Designer.

Please let me know if you require further assistance.

Regards,
Dimitar
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

0
thelostleaf
Top achievements
Rank 2
answered on 19 Mar 2021, 05:07 PM
Yes! This worked perfect! Thank you Dimitar. 
Tags
Report Designer (standalone)
Asked by
thelostleaf
Top achievements
Rank 2
Answers by
thelostleaf
Top achievements
Rank 2
Dimitar
Telerik team
Share this question
or