[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Passing Integrated SSRS Report Parmeters by URL using QueryString

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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Windocks is an independent port of Docker's open source to Windows.   This article introduces the use of SQL Server in containers, with integrated support of SQL Server database cloning.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed

650 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