Solved

Passing Integrated SSRS Report Parmeters by URL using QueryString

Posted on 2013-06-21
4
1,603 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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction Earlier I wrote an article about the new lookup functions (http://www.experts-exchange.com/A_3433.html) that ship with SQL Server 2008 R2.  In this article I’m going to show you another new feature of SSRS 2008 R2, this time in the vis…
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

773 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