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

Pass variable from webpage into Report userfunction

1 Answer 95 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
Lars asked on 22 Mar 2011, 01:25 PM


Is is possible to pass a variable into a userfunction, when not using Reportparameters that have been setup inside the Design mode?

Right now I am passing parameters from the associated webpage via a sqldatasource all set up programatically on the aspx page, and that part works fine. But now I would like to send variables into userfunctions located inside the code behind page for the report. Still not using the design mode, but all should be via programming.

web aspx page:

            Dim sqlDataSource1 As New SqlDataSource()

            sqlDataSource1.ProviderName = "System.Data.SqlClient"

            sqlDataSource1.ConnectionString = "Data Source= etc"

            sqlDataSource1.SelectCommand = strSQL

            Dim parFakturaNrStart As New Telerik.Reporting.Parameter()

            parFakturaNrStart.Value = "112112"

            sqlDataSource1.Parameters.Add("@parFakturaNrStart", DbType.String, parFakturaNrStart.Value)

            Dim parFakturaNrEnd As New Telerik.Reporting.Parameter()

            parFakturaNrEnd.Value = "112312"

            sqlDataSource1.Parameters.Add("@parFakturaNrEnd", DbType.String, parFakturaNrEnd.Value)

    Me.ReportViewer1.Report = New basic_report

            Dim report As Telerik.Reporting.Report = DirectCast(Me.ReportViewer1.Report, Telerik.Reporting.Report)

            report.DataSource = sqlDataSource1

' code here to send to the userfunction

This part takes care of the main report itself and works just fine. That is, the main report renders on the webpage without a problem.

But what do I have to do on the aspx page and/or reports code behind page, in order to send variables or a "parameter" to be picked up by the User function in its Expression?

Inside Edit Expression dialog:

{MyTelerikReportsClassLib.basic_report.getAllInvoicesInSelectionForDisplay(outgoing_variable1, outgoing_variable2)}

Report code behind page:

Function getAllInvoicesInSelectionForDisplay(incoming_variable_here1 as string, incoming_variable_here2 as string )

' further code here

' actually another SQL query to output its result at the end of this function

Return something

End Function

Please advise how to do this.

Best regards


1 Answer, 1 is accepted

Sort by
Telerik team
answered on 25 Mar 2011, 06:22 PM
Hi Lars,

You can use a Report Parameter and initialize its value in the same place where you initialize the data. After that you can use this parameter in any expression in the report.

the Telerik team
General Discussions
Asked by
Top achievements
Rank 1
Answers by
Telerik team
Share this question