Fervent Coder

Coding Towards Utopia...by Rob Reynolds
posts - 278 , comments - 431 , trackbacks - 0

My Links

News


Rob Reynolds

Subscribe to Fervent Coder RSS
Subscribe to Fervent Coder by Email

About Me

I manage several open source projects. Need...
   ...package management for Windows?
   ...automated builds?
   ...database change management (migrations)?
   ...your application to check email?
   ...a monitoring utility?

I also write for



Like what you are reading? Want to buy me a cup of coffee?
PayPal - The safer, easier way to pay online!

Article Categories

Archives

Post Categories

Image Galleries

Sites

Reporting Services 2005 BUG - Report Linking and Paging - ASP.NET Report Viewer

Download Solution - ReportingTests.zip

There is an interesting thing that happens when you use Reporting Services 2005.  You find that sometimes things don't quite work like you want them to and you don't know why.  Such as sorting on a boolean (not going to happen). Or Rich textboxes. Nope, that's vNext. Or wanting it to actually USE the white space that I have put into the report instead of ignoring it on a web page (pre tag anyone?). So what you do instead is start looking for ways around these little annoyances.  Then you come across a gem like this and you think it must be a bug.  As for a workaround, I haven't thought of one yet.  

 Solution Items  Conditions:

  • ASP.NET Report Viewer using Remote Reports
  • Report that links to another report
  • Both reports return more than one page
  • Reporting Services installed

So what we've found is that when you have two reports where one navigates to the other, if you click on the second page of the second report, it takes you to the second page of the original report.  If you click it again, it works appropriately.  This is definitely a no-go for production code and this may delay our ship date because I would think this is definitely undesirable.

If you want to skip all of this, go straight to execution.

Web Application

So below you see I have a simple ASP.NET page where I am putting a button and a report viewer control on the page.

ASP.NET Page:

<%@ page language="vb" autoeventwireup="false" codebehind="Default.aspx.vb" inherits="ReportingTests._Default" %>
<%@ register assembly="Microsoft.ReportViewer.WebForms, Version=8.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>Reports</title>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <asp:button id="btnSubmitReport" runat="server" enableviewstate="false" text="Submit" />&nbsp;<br />
            <rsweb:reportviewer id="rvReports" runat="server" processingmode="Remote" width="98%" height="800px" showparameterprompts="False" />
        </div>
    </form>
</body>
</html>
 
My code behind is also pretty simple.  I am basically wiring up to the remote report and displaying it on the page.  Again, not too much logic involved in that.

CodeBehind:

Imports System.Configuration
Imports Microsoft.Reporting.WebForms
 
Partial Public Class _Default
    Inherits System.Web.UI.Page
 
    Protected Sub btnSubmitReport_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmitReport.Click
        Dim rpt As ServerReport = rvReports.ServerReport()
        rpt.ReportServerUrl = New System.Uri(ConfigurationManager.AppSettings("ReportURL").ToString)
        rpt.ReportPath = ConfigurationManager.AppSettings("ReportPath").ToString & "/Main"
        rpt.Refresh()
    End Sub
 
End Class

 

 

The web.config file I have added two appSetting key's where I am pointing to the reporting services url and the report path where I deployed my report.

Web.Config:

<appSettings>
  <add key="ReportURL" value="http://localhost/ReportServer"/>
  <add key="ReportPath" value="/ReportTest"/>
</appSettings>

Data Project

I have also included a data project in the project that has a view and a sproc that need to be run on Northwind. If you don't have northwind installed you can download and install the one on Microsoft and install it on SQL Server 2005 and run it in SQL Server 2000 Compatibility Mode.

USE NorthWind
GO
 
CREATE VIEW vwCustomerOrders AS 
SELECT 
    c.CustomerID
    ,c.CompanyName
    ,c.ContactName
    ,c.ContactTitle
    ,c.Address
    ,c.City
    ,c.Region
    ,c.PostalCode
    ,c.Country
    ,c.Phone
    ,c.Fax
    ,o.OrderID
    ,o.EmployeeID
    ,o.OrderDate
    ,o.RequiredDate
    ,o.ShippedDate
    ,o.ShipVia
    ,o.Freight
    ,o.ShipName
    ,o.ShipAddress
    ,o.ShipCity
    ,o.ShipRegion
    ,o.ShipPostalCode
    ,o.ShipCountry
FROM [Northwind].[dbo].[Customers] c
INNER JOIN [Northwind].[dbo].[Orders] o
    ON c.CustomerID = o.CustomerID
 
DECLARE @SPName VarChar(100)
SET @SPName = 'uspOrderDetails'
IF NOT EXISTS(SELECT * FROM sysobjects WHERE [name] = @SPName)
  BEGIN
    DECLARE @SQL VarChar(1000)
    SET @SQL = 'CREATE PROCEDURE ' + @SPName + ' AS'
    EXECUTE(@SQL)
  END
PRINT 'Updating Procedure ' + @SPName
GO
 
ALTER PROCEDURE uspOrderDetails
    @OrderID    Int
AS
  BEGIN
    SELECT 
        od.OrderID
        ,od.ProductID
        ,od.UnitPrice
        ,od.Quantity
        ,od.Discount
    FROM [Northwind].[dbo].[Order Details] od
    WHERE 
        OrderID = @OrderID
 
    RETURN(0)
  END
 

Report Project

Now we move onto the other side of the project and that is the two reports.  These reports make a connection to Northwind. 

The main report that pulls in all of the customer's and their orders.

main report

dataset for the main report  

The blue textbox above is where the Navigation to the second report occurs.  It also passes a parameter.

Navigation to OrderDetail Subreport Parameters for to pass to the subreport

The OrderDetail Report is below.  You can see that it is also a pretty simple report.  I inserted a page break at the bottom of the table to simulate a second page.  The part with the line and below is what will be page two.  This report takes a parameter input for OrderID and passes that to the stored procedure.

OrderDetail Subreport

Report Parameters for OrderDetail Subreport

Dataset for OrderDetail Subreport Subreport dataset parameters

 

Execution and Bug

And now that we are done with all of the code, we can actually see what the bug is.  I will give you a second to ensure all of the below is good.

  1. Ensure you have run both scripts on your Northwind instance.
  2. Ensure you have a good connection string for dsNorthwind (the data source) in the Reports project.
  3. Ensure that you have deployed the reports to the server by right clicking on the reports and selecting deploy. 
  4. Update the web.config for any changes to the reporting server you may have made.

All ready? Great! Now we fire up the application and we get the main page.  We click on the submit button and we get a report.

The main report in ASP.NET

Now we click the link to take us to the other report.  Go ahead, click on one of the links. 

OrderDetail Subreport in ASP.NET

Now that you are in the second report, try to view the second page.  Notice it takes you back to the first report. 

The second page of the original report?! WTF?!

Click on another link in that first report.  Now click on the second page.  Now you stay on the second report. 

The second page of the subreport

 

This bug brought to you by Microsoft. :D

Only in ASP.NET. Only with SQL Reporting Services.  If you made it this far it means you are probably responding to the post in Microsoft forums for this bug. :D

Print | posted on Wednesday, November 21, 2007 10:10 PM | Filed Under [ Code ApplicationsToysOther ]

Feedback

Gravatar

# re: Reporting Services 2005 BUG - Report Linking and Paging - ASP.NET Report Viewer

Microsoft Forums Posting : http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2444497&SiteID=1&mode=1
11/21/2007 11:42 PM | Robz
Gravatar

# re: Reporting Services 2005 BUG - Report Linking and Paging - ASP.NET Report Viewer

Microsoft Bug Report: http://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=311781
11/22/2007 12:48 AM | Robz
Gravatar

# re: Reporting Services 2005 BUG - Report Linking and Paging - ASP.NET Report Viewer

Okay, very related issue:

Go to the subreport. Try printing it. Now try to export it.

It prints AND exports the original report.
The second time through it prints and exports the subreport.
11/28/2007 3:52 PM | Robz
Gravatar

# re: Reporting Services 2005 BUG - Report Linking and Paging - ASP.NET Report Viewer

The Fix - http://geekswithblogs.net/robz/archive/2007/11/29/reporting-services-fix---report-viewer-2005-sp1-redistributable-package.aspx
12/15/2007 8:54 AM | Robz
Gravatar

# re: Reporting Services 2005 BUG - Report Linking and Paging - ASP.NET Report Viewer

hi i did whatever u explained but i dn't know where will get dataset property box.
4/17/2008 2:39 AM | su
Gravatar

# re: Reporting Services 2005 BUG - Report Linking and Paging - ASP.NET Report Viewer

Su I am not sure what you mean. Would you be able to elaborate a little?
4/18/2008 12:32 AM | Fervent Coder
Gravatar

# re: Reporting Services 2005 BUG - Report Linking and Paging - ASP.NET Report Viewer

means above one dataset property box is there knw that one we r not getting actually i am working on ver.5
i want paging from one report to another plz explain it properly.
4/19/2008 5:01 AM | su
Gravatar

# re: Reporting Services 2005 BUG - Report Linking and Paging - ASP.NET Report Viewer

hi i want subtotal of first page in the top of next page in rdlc reports.
4/19/2008 5:03 AM | su
Gravatar

# re: Reporting Services 2005 BUG - Report Linking and Paging - ASP.NET Report Viewer

Well, actually this is all on different servers where we actually have it. It's all about pointing to the right place for each where you set up those connections.
9/24/2008 3:54 PM | Robz
Comments have been closed on this topic.

Powered by: