Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Passing parameters from ASP page to report viewer SSRS report

Posted on 2009-04-01
6
Medium Priority
?
1,134 Views
Last Modified: 2016-02-13
1) What do I have to do to the SSRS report? (create parameters?)
2) What do I have to do on the ASP page to pass it through?
Do you have a code snippet?

I found some answers in the knowledge base, but had broken links.
Using SSRS 2005, VS 2008.
0
Comment
Question by:guspan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 27

Accepted Solution

by:
Chris Luttrell earned 1500 total points
ID: 24044105
This is the code where we load the parameters and is called by this line
rptViewer.ServerReport.SetParameters(loadKPIParameters(report))
    #region KPI Recognition Methods
    private ReportParameter[] loadKPIParameters(string reportPath)
    {
        //declaring and initializing local variables
        MyAppAccordionFilter filter = (MyAppAccordionFilter)Session["MyAppAccordionFilter"];
        ReportParameter[] rptParams = null;
        ReportServerQuery.ReportService.ReportParameter[] thisRptParams = null;
        string[] rptAuth = MyAppApplication.getMyAuthenticatedUserGroup();
        ArrayList lparamList = new ArrayList();
        thisRptParams = ReportServerQuery.ReportServerQuery.GetParametersForReport(rptAuth, reportPath);
 
        //looping through the parameters and filling in those it recognizes
        for (int i = 0; i < thisRptParams.Length; i++)
        {
            if (thisRptParams[i].PromptUser)
            {
                switch (thisRptParams[i].Name)
                {
                    case "FilterLevel": //Scorecard Parameter
                        lparamList.Add(new ReportParameter(thisRptParams[i].Name, getFilterLevel(filter)));
                        break;
                    case "FilterId": //Scorecard Parameter
                        lparamList.Add(new ReportParameter(thisRptParams[i].Name, getFilterId(filter)));
                        break;
                    case "FiscalYear":
                        lparamList.Add(new ReportParameter(thisRptParams[i].Name, getFiscalYear(filter)));
                        break;
                    case "FiscalPeriod":
                        lparamList.Add(new ReportParameter(thisRptParams[i].Name, getFiscalPeriod(filter)));
                        break;
                    case "ReportLevel":
                        lparamList.Add(new ReportParameter(thisRptParams[i].Name, getReportLevel(filter)));
                        break;
                    case "NAFD_ID":
                        lparamList.Add(new ReportParameter(thisRptParams[i].Name, getNAFD_ID(filter)));
                        break;
                }
            }
        }
 
        //creating a list of parameters to hand to the viewer
        rptParams = new ReportParameter[lparamList.Count];
        for (int i = 0; i < lparamList.Count; i++)
            rptParams[i] = (ReportParameter)lparamList[i];
 
        //returning the parameters
        return rptParams;
    }

Open in new window

0
 

Author Comment

by:guspan
ID: 24072854
From a C# Webpage?
0
 
LVL 27

Expert Comment

by:Chris Luttrell
ID: 24074349
Yes, this is from the code behind in an aspx.cs page.
0
 

Author Comment

by:guspan
ID: 24088423
Not too familiar with c#, but loadKPIparameters is a arbitrary method I name?
This isn't specific to KPI in SSAS is it?
0
 
LVL 27

Expert Comment

by:Chris Luttrell
ID: 24088654
No, not part of SSAS that is just our method name in the code I copied.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction As you'll probably know, a data region in a SQL Server Reporting Services report can be linked to only one dataset.  This makes it troublesome when you need to display data from more than one dataset in the same data region.  SQL Serve…
This code started out as a fix for a customer that had incoming data that was hunderds of numbers and words long that was to fit in one column. The problem was that the customer did not want to split words or numbers when wrapping in the column. …
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question