6 Answers, 1 is accepted
In the following example you can see how to access a session variable and pass it to the report parameter:
report1.ReportParameters("InvoiceID").Value = System.Web.HttpContext.Current.Session("InvoiceID")
Let me know whether the proposed solution helps.
All the best,
Peter
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items.
The following code snipped demonstrates how to access a session variable from a Report.
System.Web.HttpContext.Current.Session["InvoiceID"];
Just have in mind that if you are using a separate class library to create the Report you will have to reference the System.Web.dll assembly.
I have attached a sample project.
Greetings,
Peter
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items.
If I have a dataset in session I'm assuming I can do the same thing and use it in my NeedDataSource event.....
Telerik.Reporting.Processing.Table table3 = (Telerik.Reporting.Processing.Table)sender;
DataSet dataSet3 = new DataSet();
dataSet3 = (DataSet)System.Web.HttpContext.Current.Session["PreviewInvoice"];
table3.DataSource = dataSet3;
Assuming there is a valid dataset within my session["PreviewInvoice"] variable, will this work?
I am using vs2019 and telerik reporting trial. The sample earlier in this thread will not load in vs2019 so I am unable to see how it works or where i put the code.
Can you please send me a sa,ple that will show the vs2019 methods
Cheers
Hi Bill,
I tested to open Peter Raykov's attachment from 18 Mar 2010 11:26 AM in VS 2019. The Visual Studio 2019 successfully converted the solution and opened it - see the attached screenshot.
Note that this thread is from 2010 and the sample was created with Telerik Reporting version 4.0.10.312. It is a Web Site project that cannot be automatically upgraded to a newer version. The sample demonstrates an approach that is suitable only for the legacy Web Forms Report Viewer. This viewer is no longer actively developed.
For WebForms projects I strongly recommend using the Html5 Web Forms Report Viewer instead. Here are some useful links that will help you start with it:
Consider also opening a Support ticket where to explain your requirement. We may give further advice on how to achieve it with the newer viewer.
Regards,
Todor
Progress Telerik
Our thoughts here at Progress are with those affected by the outbreak.
Hi Bryan,
You are right that the report needs to be resolved several times by the Reporting REST Service. The reason for this is explained in the 'operationOrigin' part of the article section How does the REST Service know which report definition to use and what parameter values to apply?
Regarding the HttpContext, it is not always accessible in the Report class, as when the rendering starts it happens in another thread that doesn't have access to the HttpContext.
As a workaround, you may use a Report Parameter or UserIdentity.Current to pass the required information to the report. For details I suggest the following resources: