locked
Passing Parameters Issue RRS feed

  • Question

  • Hi I am brand new to the programming world and am looking for some guidance on what I have done wrong. I am trying to see if a report has a ID a parameter and then if it does pass it back into report viewer. What I have for code is as follows, any help is GREATLY appreciated...thanks!...

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    
    namespace SSRSReportViewer
    {
        public partial class SSRSViewer : System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {
                string ID = "";
                string reportName = Page.Request.QueryString["name"].ToString();
                if (Session["ID"] != null)
                    ID = Session["ID"].ToString();
                else
                {
                    this.rtViewer.ShowParameterPrompts = true;
                    Microsoft.Reporting.WebForms.ReportParameter param = 
                        new Microsoft.Reporting.WebForms.ReportParameter();
                    param.Name ="@id";
                    Microsoft.Reporting.WebForms.ReportParameter[] reportParameterCollection =
                        new Microsoft.Reporting.WebForms.ReportParameter[2];
                    
                    reportParameterCollection[0] =
                        new Microsoft.Reporting.WebForms.ReportParameter();
                    reportParameterCollection[0].Name ="UserID";
                    
                    reportParameterCollection[0].Values.Add(ID.Trim());
                    reportParameterCollection[0].Visible =false;
                    reportParameterCollection[1] = new Microsoft.Reporting.WebForms.ReportParameter();
                    reportParameterCollection[1].Name ="ID";
                    this.rtViewer.ServerReport.SetParameters(param);
                    this.rtViewer.ServerReport.Refresh();
                }
                lblTest.Text = Request.Url.PathAndQuery;
                this.rtViewer.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Remote;
                this.rtViewer.ServerReport.ReportServerUrl = new System.Uri(Properties.Settings.Default.ReportServer);
                this.rtViewer.ServerReport.ReportPath = reportName;
                this.rtViewer.ShowCredentialPrompts = false;
                this.rtViewer.ShowPageNavigationControls = false;
                this.rtViewer.ShowPrintButton = false;



    • Edited by Dummy yoyo Wednesday, February 1, 2012 4:06 AM Adjust the code style.
    • Moved by Mike Dos Zhang Wednesday, February 1, 2012 5:05 AM web develop problem (From:Visual C# General)
    Monday, January 30, 2012 3:00 PM

Answers

All replies