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

Telerik Reports - Parameter Binding

1 Answer 280 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
James
Top achievements
Rank 1
James asked on 14 Aug 2015, 11:51 AM

Hello Telerik Team,

I'm find it difficult to pass a report parameter value from the client side and access the particular value within the Telerik report class.

cshtml code.

@{
        TypeReportSource typeReportSource = new TypeReportSource() { TypeName = typeof(TestTelerik.Website.Reports.MySales).AssemblyQualifiedName };
        typeReportSource.Parameters.Add("param", "A");
    }
     
    @(Html.TelerikReporting().ReportViewer()
    .Id("reportViewer1")
    .ServiceUrl(Url.Content("~/api/reports/"))
    .TemplateUrl(Url.Content("~/ReportViewer/templates/telerikReportViewerTemplate-9.1.15.624.html"))
    .ReportSource(typeReportSource)
    .ViewMode(ViewMode.Interactive)
    .ScaleMode(ScaleMode.Specific)
    .Scale(1.0)
    .PersistSession(false)
    .PrintMode(PrintMode.AutoSelect)
    .Deferred()

 

I have defined a method to trigger NeedDataBind event which is as follows.

private void ProductReport_NeedDataSource(object sender, EventArgs e)
{
      var myParam = this.ReportParameters["param"].Value.ToString();
}

 

Also i have defined report parameter as follows. However, this.ReportParameters["param"].Value is always null. Could I know what am I doing wrong in my code.

reportParameter1.Name = "param";
this.ReportParameters.Add(reportParameter1);

1 Answer, 1 is accepted

Sort by
0
Stef
Telerik team
answered on 18 Aug 2015, 12:07 PM
Hello James,

The passed parameters values can be obtained in report events through the processing report's Parameters collection e.g. Using Report Events.

I will appreciate it if you elaborate on the reason to access parameters values in code.

Regards,
Stef
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
Tags
General Discussions
Asked by
James
Top achievements
Rank 1
Answers by
Stef
Telerik team
Share this question
or