Solved

Passing Integrated SSRS Report Parmeters by URL using QueryString

Posted on 2013-06-21
4
1,695 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
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.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

717 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