?
Solved

Passing Integrated SSRS Report Parmeters by URL using QueryString

Posted on 2013-06-21
4
Medium Priority
?
1,727 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 2000 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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
I have a large data set and a SSIS package. How can I load this file in multi threading?
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.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.
Suggested Courses

801 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