public static void ReadUsingReportViewer(string FILE_NAME) { Microsoft.Reporting.WebForms.ReportViewer ReportViewer1 = new Microsoft.Reporting.WebForms.ReportViewer(); // ReportViewer1.LocalReport.ReportPath = "GM_Gebaeudestammdaten_Wincasa.rdl"; ReportViewer1.LocalReport.ReportPath = FILE_NAME; // Console.WriteLine(ReportViewer1.LocalReport.ReportEmbeddedResource); Microsoft.Reporting.WebForms.ReportParameterInfoCollection x = ReportViewer1.LocalReport.GetParameters(); foreach (Microsoft.Reporting.WebForms.ReportParameterInfo pi in x) { Console.WriteLine(pi.Name); } // Next pi Microsoft.Reporting.WebForms.ReportDataSourceCollection dsc = ReportViewer1.LocalReport.DataSources; foreach (Microsoft.Reporting.WebForms.ReportDataSource rds in dsc) { Console.WriteLine(rds.Name); Console.WriteLine(rds.Value); } // Next rds } // End Sub ReadUsingReportViewer
protected override void CreateChildControls() { rv = new Microsoft.Reporting.WebForms.ReportViewer(); SPWeb rootWeb = SPContext.Current.Site.RootWeb; if (UseDefaults) { ReportingServicesURL = EPMLiveCore.CoreFunctions.getWebAppSetting(SPContext.Current.Site.WebApplication.Id, "ReportingServicesURL"); try { Integrated = bool.Parse(EPMLiveCore.CoreFunctions.getWebAppSetting(SPContext.Current.Site.WebApplication.Id, "ReportsUseIntegrated")); } catch { } } else { ReportingServicesURL = PropSRSUrl; Integrated = IsIntegratedMode; } if (string.IsNullOrEmpty(PropReportPath)) { error = "Report Path has not been set. Please configure the Report Path."; } else if (ReportingServicesURL == null || ReportingServicesURL == "") { error = "ReportingServicesURL has not been set."; } else if (Integrated && !(rootWeb.GetFile(rootWeb.Url + "/Report Library" + PropReportPath + ".rdl").Exists)) { error = "Please configure the correct Report Path."; } else { try { rv.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Remote; rv.ServerReport.ReportServerUrl = new Uri(ReportingServicesURL); if (Integrated) { rv.ServerReport.ReportPath = rootWeb.Url + "/Report Library" + PropReportPath + ".rdl"; } else { rv.ServerReport.ReportPath = PropReportPath; } rv.ShowToolBar = true; rv.SizeToReportContent = true; rv.EnableTheming = true; rv.CssClass = "ms-toolbar"; rv.EnableTheming = true; rv.Width = new Unit(59, UnitType.Percentage); rv.ControlStyle.Width = new Unit(79, UnitType.Percentage); Microsoft.Reporting.WebForms.ReportParameterInfoCollection rpic = rv.ServerReport.GetParameters(); List <Microsoft.Reporting.WebForms.ReportParameter> arrParams = new List <Microsoft.Reporting.WebForms.ReportParameter>(); foreach (Microsoft.Reporting.WebForms.ReportParameterInfo rpi in rpic) { if (rpi.Prompt == "") { switch (rpi.Name) { case "URL": Microsoft.Reporting.WebForms.ReportParameter rp = new Microsoft.Reporting.WebForms.ReportParameter(rpi.Name, HttpUtility.UrlEncode(SPContext.Current.Web.ServerRelativeUrl)); arrParams.Add(rp); break; case "SiteId": Microsoft.Reporting.WebForms.ReportParameter rp1 = new Microsoft.Reporting.WebForms.ReportParameter(rpi.Name, SPContext.Current.Site.ID.ToString()); arrParams.Add(rp1); break; case "WebId": Microsoft.Reporting.WebForms.ReportParameter rp2 = new Microsoft.Reporting.WebForms.ReportParameter(rpi.Name, SPContext.Current.Web.ID.ToString()); arrParams.Add(rp2); break; case "UserId": Microsoft.Reporting.WebForms.ReportParameter rp3 = new Microsoft.Reporting.WebForms.ReportParameter(rpi.Name, SPContext.Current.Web.CurrentUser.ID.ToString()); arrParams.Add(rp3); break; case "Username": Microsoft.Reporting.WebForms.ReportParameter rp4 = new Microsoft.Reporting.WebForms.ReportParameter(rpi.Name, HttpContext.Current.User.Identity.Name); arrParams.Add(rp4); break; } } } if (arrParams.Count > 0) { rv.ServerReport.SetParameters(arrParams); } } catch (Exception ex) { error = ex.Message; } } Controls.Add(rv); }