Passing multiple parameters from Custome WebPart to Reporter Webpart Reporting Services

I work with Reporting Services in Sharepoint mode, I can show the report in the Reporting Services Sql Server report, the report has several parameters. My question is how to pass more than one parameter from the custome web page to this report.

I can pass one parameter by implementing the ITransformableFilterValues ​​interface in the user web part, what I want to do is pass several parameters.

Ex: if there are 2 parameters in the report, then I must map them to the control in the web part.

Any help or guidance appreciated.

+4
source share
2 answers

Here is the code for the custom web part:

using System; using System.Collections.Generic; using System.ComponentModel; using System.Text; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using aspnetwebparts = System.Web.UI.WebControls.WebParts; //using Microsoft.Office.Server.Utilities; using wsswebparts = Microsoft.SharePoint.WebPartPages; //using Microsoft.SharePoint.Portal.WebControls; using System.Collections.ObjectModel; using Microsoft.SharePoint.Utilities; using System.Data; using System.Collections; namespace CustomWebPart { /// <summary> /// Used to provide filter values for the status report. /// </summary> public class StatusReportFiler : aspnetwebparts.WebPart, wsswebparts.ITransformableFilterValues { DropDownList ddlCategory; ListItem lstItem; Label lblCaption; public virtual bool AllowMultipleValues { get { return false; } } public virtual bool AllowAllValue { get { return true; } } public virtual bool AllowEmptyValue { get { return false; } } public virtual string ParameterName { get { return "Category"; } } public virtual ReadOnlyCollection<string> ParameterValues { get { string[] values = this.GetCurrentlySelectedCategory(); return values == null ? null : new ReadOnlyCollection<string>(values); } } protected override void CreateChildControls() { lblCaption = new Label(); lblCaption.Text = "&nbsp; Category:&nbsp;"; Controls.Add(lblCaption); ddlCategory = new DropDownList(); ddlCategory.AutoPostBack = true; lstItem = new ListItem(); lstItem.Text = "Select All Category"; lstItem.Value = "0"; ddlCategory.Items.Add(lstItem); lstItem = null; lstItem = new ListItem(); lstItem.Text = "BING"; lstItem.Value = "Bing"; ddlCategory.Items.Add(lstItem); lstItem = null; lstItem = new ListItem(); lstItem.Text = "Google"; lstItem.Value = "Google"; ddlCategory.Items.Add(lstItem); lstItem = null; Controls.Add(ddlCategory); // base.CreateChildControls(); } [aspnetwebparts.ConnectionProvider("Category Filter", "ITransformableFilterValues", AllowsMultipleConnections = true)] public wsswebparts.ITransformableFilterValues SetConnectionInterface() { return this; } protected override void OnPreRender(EventArgs e) { base.OnPreRender(e); } public string[] GetCurrentlySelectedCategory() { string[] selCategory = new string[1]; selCategory[0] = ddlCategory.SelectedValue; return selCategory; } protected override void RenderContents(HtmlTextWriter htmlWriter) { /*htmlWriter.Write("<table border=\"0\" width=\"100%\">"); htmlWriter.Write("<tr><td>"); lblCaption.RenderControl(htmlWriter); htmlWriter.Write("</td></tr>"); htmlWriter.Write("<tr><td>"); lblCaption.RenderControl(htmlWriter); htmlWriter.Write("</td></tr>"); htmlWriter.Write("</table>");*/ this.EnsureChildControls(); RenderChildren(htmlWriter); } } } 
  • Once you create this website, deploy it to SharePoint. Create a web page in Sharpoint, add a custom web part to the page. After adding it, you can see a drop-down list with values ​​in Webpart.

  • In another section for adding web parts, add the Sql Server Reporting Sevess ReportViewer web part and set the report URL in the properties section and click "apply", this report should have the same parameter name as in the Custom Webpart.

  • In the custom web part, click Modify β†’ Connections - Send Category Filter - ReportViewer - AAAA (this is the name of the report I Think). A window will appear with the section "Displaying the category Filer Category to Filtered" in the report and click "Finish." This will pass the value from Webpart to the report.

Hope this helps.

+6
source

I'm not sure about SharePoint integrated mode, but ReportServer correctly accepts the parameters passed through the URL string.

+1
source

Source: https://habr.com/ru/post/1305809/


All Articles