Link to home
Start Free TrialLog in
Avatar of Moti Mashiah
Moti MashiahFlag for Canada

asked on

ReporViewer ASP.NET

Hi guys,

I have implemented reporting viewer in my solution and everything working perfectly.
I'm looking for a solution to how can I direct many reports to this reporting page:

For example:
I'm passing value to my C# code, look at the link code below.

 <a title="Inventory Count Parse" class="icon-bar-chart icon-2x" target="_blank" href="http://localhost:1863/ReportViewer.aspx?reference=@item.Reference"></a>

Open in new window



Then in my code it is written like that way:

 public partial class ReportViewer : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string rr = Request.QueryString["reference"];
            ShowReport(rr);
        }

        private void ShowReport(string rr)
        {
            try
            {
                //report url  
                string urlReportServer = "http://srv-db-01:8081/ReportServer";

                // ProcessingMode will be Either Remote or Local  
                ReportViewer1.ProcessingMode = ProcessingMode.Remote;

                //Set the ReportServer Url  
                ReportViewer1.ServerReport.ReportServerUrl = new Uri(urlReportServer);

                // setting report path  
                //Passing the Report Path with report name no need to add report extension   
                ReportViewer1.ServerReport.ReportPath = "/ERP/Parse Web App Inventory Count";
                ReportViewer1.ServerReport.ReportPath = "/ERP/Inv item Movement 90";

                //Set report Parameter  
                //Creating an ArrayList for combine the Parameters which will be passed into SSRS Report  
                ArrayList reportParam = new ArrayList();
                reportParam = ReportDefaultPatam(rr);

                ReportParameter[] param = new ReportParameter[reportParam.Count];
                for (int k = 0; k < reportParam.Count; k++)
                {
                    param[k] = (ReportParameter)reportParam[k];
                }  

                //pass credential as if any... no need to pass anything if we use windows authentication  
                IReportServerCredentials irc = new CustomReportCredentials("dddd", "dddd", "ddd.dd");
                ReportViewer1.ServerReport.ReportServerCredentials = irc;


                //pass parameters to report  
                ReportViewer1.ServerReport.SetParameters(param);   
                ReportViewer1.ServerReport.Refresh();
            }
            catch (Exception ex)
            {

                throw ex;
            }
        }
       
        private ArrayList ReportDefaultPatam(string rr)
        {
            ArrayList arrLstDefaultParam = new ArrayList();
            arrLstDefaultParam.Add(CreateReportParameter("reference", rr));
            arrLstDefaultParam.Add(CreateReportParameter("ilc", rr));
            //arrLstDefaultParam.Add(CreateReportParameter("ReportSubTitle", "Sub Title of Report"));
            return arrLstDefaultParam;
        }

Open in new window


As you see below c# code I added another report path and I linked it with other link through the view.

Here is my question: How can I pass dynamic path from the view as I have many other reports and the path change for each report.

Please, let me know if there is any other way to do it.

Thank,
ASKER CERTIFIED SOLUTION
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Moti Mashiah

ASKER

Thank