Solved

Passing Integrated SSRS Report Parmeters by URL using QueryString

Posted on 2013-06-21
4
1,563 Views
Last Modified: 2013-06-26
I have a report embedded in a .net page via the ReportViewer control in vs.   The application can't access reportserver directly because it is on seperate server behind a firewall.  So i can't use the usual url methods to pass parameters/properties.

I need a seperate application to pass 2 parameters to this aspx page in a url but I'm not sure how to get those parameters into the <ServerReport ReportPath="/..." /> string in the aspx page (below).  

So the url I have generating looks something like what they show in the example for the Httprequest.QueryString property described in link below.  

Example URL passing parameters-->  

www.mywebsite.com/applicationfiles/myreport.aspx?reportparam1=5&reportparam2=johnson

QueryString:

http://msdn.microsoft.com/en-us/library/system.web.httprequest.querystring.aspx

Here is the code I have for the simple .net page:  
<%@ Register assembly="Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" namespace="Microsoft.Reporting.WebForms" tagprefix="rsweb" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
    
        <rsweb:ReportViewer ID="report" runat="server" Height="415px" 
            Width="734px" Font-Names="Verdana" Font-Size="8pt" 
            InteractiveDeviceInfos="(Collection)" ProcessingMode="Remote" 
            WaitMessageFont-Names="Verdana" WaitMessageFont-Size="14pt">
            <ServerReport ReportPath="/GIS/map/mapreport" 
                ReportServerUrl="https://myserver/reportserver" />
        </rsweb:ReportViewer>
    
    </div>
    </form>
</body>
</html>

Open in new window

DEFAULT CODE BEHIND:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
}

Open in new window

0
Comment
Question by:Gregory3
  • 2
  • 2
4 Comments
 
LVL 12

Expert Comment

by:duttcom
ID: 39267362
I'm not sure if this helps, but this is some button code which uses the values from two dropdowns on an aspx page as parameters in a url to a report on my report server.

protected void btn_GetManifest_Click(object sender, EventArgs e)
    {
        string DelDate = dd_DelMonth.SelectedValue;
        string DelShip = dd_ShipNames.SelectedValue;
        string reportURL = "http:/" + "/serverX/reportserver?" + "/POsByShipment/ShipmentManifest&rs:Command=Render&DELIVERY_MONTH=" + DelDate + "&CONTAINER=" + DelShip;
        Response.Redirect(reportURL);
    }

Open in new window


The resulting url of the report on the report server is -

http://serverX/ReportServer/Pages/ReportViewer.aspx?/POsByShipment/ShipmentManifest&rs:Command=Render&DELIVERY_MONTH=07/13&CONTAINER=LAHORE

Open in new window

0
 

Author Comment

by:Gregory3
ID: 39272072
Thank you for the response.  Unfortunately I can't use the standard "...ReportServer/pages/reportViewer.aspx..."   I have to integrate the report within a seperate aspx page.  I can get the URL string generated for myintegratedreport.aspx.   I'm looking for how to pass the parameters to this aspx page as such:  myintegratedreport.aspx?param1=5.  I'm assuming using Httprequest.QueryString
0
 
LVL 12

Accepted Solution

by:
duttcom earned 500 total points
ID: 39273312
Ah ha! In that case, here is an example of some code which once again uses the values from two dropdowns and passes them as parameters to another aspx page, using request.querystring

The button code on the page that passes the parameters is -
protected void Button4_Click(object sender, EventArgs e)
{
    //Get field values from dropdowns
    string passShip = ShipsDD.SelectedValue;
    string passDelDate = DelDateDD.SelectedValue;
    Response.Redirect("OrderReview.aspx?Ship=" + passShip + "&DelDate=" + passDelDate);
}

Open in new window


And then in the code for the page that accepts the parameters -

protected void Page_Load(object sender, EventArgs e)
    {
        string myShip = Request.QueryString["Ship"];
        string myDelDate = Request.QueryString["DelDate"];
        Label1.Text = myShip;
        Label2.Text = myDelDate;
    }

Open in new window


The last two lines just set some labels on the page to the parameter values.
0
 

Author Comment

by:Gregory3
ID: 39278252
Ahhh yea, that worked.  Thank you!
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
back end of ssas cube views or tables? 2 29
Ranking Based On Value 3 29
t-sql month question 8 43
Stored procedure 23 24
Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.

746 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now