Setting Reporting Parameter from Session Variables

2 posts, 0 answers
  1. SwanB
    SwanB avatar
    50 posts
    Member since:
    Oct 2006

    Posted 29 Nov 2016 Link to this post

    How can we most easily perform the follwoing directly from the Stanalone Report designer?

    //Get the current user name from the CurrentUserName Session variable
    string un = HttpContext.Current.Session["CurrentUserName"].ToString();

    //Set a value to a Report Parameter1 used in a report filter
    report1.ReportParameters["Parameter1"].Value = un;
  2. Stef
    Admin
    Stef avatar
    3610 posts

    Posted 30 Nov 2016 Link to this post

    Hello SwanB,

    The Standalone Report Designer is a desktop application. When you preview reports in it, they are processed locally in the context of the desktop application.

    Once the report is designed and included in a web application, you can get the Session variable and use it as a value for the report parameter in code e.g.:
    //specify the report that will be diplsayed via ReportSource - http://docs.telerik.com/reporting/report-sources
    var URS = new UriReportSource();
    URS.Uri = Server.MapPath("~/ReportsFolder/Report1.trdp");
     
    //specify values to be passed to report parameters
    //the ReportSource.Parameters collection is mapped to the report's ReportParameters collection by Name
    URS.Parameters.Add("Parameter1",Session["param1"].ToString());


    Regards,
    Stef
    Telerik by Progress
    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
Back to Top