This is a migrated thread and some comments may be shown as answers.

Reporting displays empty page when creating it dynamically

11 Answers 1213 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Raghavan Subramanian
Top achievements
Rank 1
Raghavan Subramanian asked on 31 Oct 2009, 12:33 PM
Hi

I tried to create report dynamically, but showing empty page.

I checked with report by debugging, it shows rows and columns count. But not binding the data.

please find the following code snippet i have used, and the report page attached.

Report1.vb

----------------
Partial Public Class Report1
    Inherits Telerik.Reporting.Report
    Public Sub New()
        InitializeComponent()
        Dim sqlConnection1 As New SqlConnection()
        sqlConnection1.ConnectionString = "Data Source=dbserver;Initial Catalog=StarflighteDecision;User ID=sa;Password=Admin123#"
        sqlConnection1.Open()
        sqlDataAdapter1 = New SqlDataAdapter("exec [daterange_report] '8/25/2009','8/27/2009' ", sqlConnection1)
        Dim dataSet As New DataSet()
        sqlDataAdapter1.Fill(dataSet)
        Me.DataSource = dataSet.Tables(0)
    End Sub
End Class

==========================================================
Default.aspx.vb

----------------------
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
      
        Dim report As IReportDocument
        report = New Report1()
        Me.ReportViewer1.Report = report
        ReportViewer1.DataBind()
       
End Sub

Please give any suggestions to solve it.

Thanks in advance.

Regards,
Ragavan

11 Answers, 1 is accepted

Sort by
0
Accepted
Steve
Telerik team
answered on 02 Nov 2009, 02:10 PM
Hello Raghavan,

The only code needed to assign a report to the web viewer is the following:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
 If Not IsPostBack Then
  Dim report1 As New Report1()
  ReportViewer1.Report = report1
 End If
End Sub

The DataBind() method is inherited from the ASP.NET controls class and is not relevant (does not do anything) in the web report viewer.

Also you provided code how you bind the report with data, but have you actually designed the report through the Report Designer and used preview to see the data? Note that simply binding a report to data would not produce any data, unless you have placed Report Items that are bound to show specific column from your dataset.

Sincerely yours,
Steve
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
David Purkey
Top achievements
Rank 1
answered on 17 Nov 2009, 05:42 PM
Steve
I have been having a similar problem - but only similar. 
My problem is the web viewer is showing the control bar in the browser but no data, when I export the report (to say a PDF) the report renders fine.

I am binding data to the report at runtime using the datasource property.
My code behind..

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Web; 
using System.Web.UI; 
using System.Web.UI.WebControls; 
using System.Xml; 
using System.Data; 
using System.IO; 
 
 
namespace Manage_TSR 
  { 
  public partial class ReportViewer : System.Web.UI.Page 
    { 
    protected void Page_Load(object sender, EventArgs e) 
      { 
          if(!IsPostBack) 
          { 
              ReportLibary.Report1 report1 = new ReportLibary.Report1(); 
              report1.DataSource = BindGridview("FY10"); 
              ReportViewer1.Report=report1
          } 
      } 
 
    public DataSet BindGridview(string strFY) 
      { 
      DataSet ds = new DataSet(); 
      DataTable dt = new DataTable(); 
      XmlDocument xmlDoc = new XmlDocument(); 
      string strReturn = null
      DataLayer GetData = new DataLayer(); 
      xmlDoc.LoadXml(GetData.GetData(strFY)); 
 
      XmlNodeList xNodeList = xmlDoc.SelectNodes("XML/ROW"); 
 
      foreach (XmlNode xNode in xNodeList) 
        { 
        strReturnstrReturn = strReturn + xNode.OuterXml; 
        } 
      strReturn = "<XML>" + strReturn + "</XML>"; 
      StringReader sReader = new StringReader(strReturn); 
      ds.ReadXml(sReader); 
      return ds; 
      } 
    } 
  } 
 

my viewer code
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ReportViewer.aspx.cs" Inherits="Manage_TSR.ReportViewer" %> 
 
<%@ Register Assembly="Telerik.ReportViewer.WebForms, Version=3.1.9.807, Culture=neutral, PublicKeyToken=a9d7983dfcc261be" 
  Namespace="Telerik.ReportViewer.WebForms" TagPrefix="telerik" %> 
 
<html> 
<head runat="server"
    <title>Report Viewer</title> 
</head> 
<body> 
    <form id="form1" runat="server"
    <div id="divReportViewer"
      <telerik:ReportViewer ID="ReportViewer1" runat="server" Height="100%" Width="100%" 
        BorderColor="#404040" BorderStyle="Solid"
      </telerik:ReportViewer> 
    </div> 
    </form> 
</body> 
</html> 

What am I missing?

David


0
Chavdar
Telerik team
answered on 18 Nov 2009, 02:42 PM
Hi David Purkey,

You have to set height 100% to all html elements that are parent to the report viewer. Please, take a look at the Report Viewer Height forum thread for more information.

All the best,
Chavdar
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
David Purkey
Top achievements
Rank 1
answered on 18 Nov 2009, 03:50 PM
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ReportViewer.aspx.cs" Inherits="Manage_TSR.ReportViewer" %> 
 
<%@ Register Assembly="Telerik.ReportViewer.WebForms, Version=3.1.9.807, Culture=neutral, PublicKeyToken=a9d7983dfcc261be" 
  Namespace="Telerik.ReportViewer.WebForms" TagPrefix="telerik" %> 
 
<html> 
<head runat="server"
    <title>Report Viewer</title> 
</head> 
<body style="height: 100%"
    <form id="form1" runat="server" style="height: 100%"
    <div id="divReportViewer" style="height:100%"
      <telerik:ReportViewer ID="ReportViewer1" runat="server" Height="100%" Width="100%" 
        BorderColor="#404040" BorderStyle="Solid"  
        Report="ReportLibary.Report1, ReportLibary, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
      </telerik:ReportViewer> 
    </div> 
    </form> 
</body> 
</html> 
 
This is the code that works - just for others having the same problem
0
Antonio Simoes
Top achievements
Rank 1
answered on 01 Mar 2010, 01:55 PM
Hello,

I have tried all the solutions posted above but I'm still getting blank report pages. But, I am able to get my report printed and/or exported to another format! It just doesn't show up on the web report viewer control!

Here's my aspx code:

 

 

 

<!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" style="height:100%">   
   
 
<head runat="server">   
<title>Untitled Page</title>   
</head>   
   
 
<body style="height:100%">   
 
<form id="form1" runat="server" style="height:100%">   
<div style="height:100%">   
<asp:PlaceHolder ID="phReports" runat="server">  
</asp:PlaceHolder>   
</div>   
 
</form>   
</body>   
</html> 
 
 

and my code-behind:

 

protected void Page_Load(object sender, EventArgs e)   
{  
 
   ReportViewer rvw = new ReportViewer();  
 
   LabelReport lbl = new LabelReport();  
 
   rvw.Width = Unit.Percentage(100);   
 
   rvw.Height = Unit.Percentage(100);   
 
   placeholder.Controls.Add(rvw);  
 
   lbl.DataSource = foldersource; // some custom business object of mine...  
 
   rvw.Report = lbl;  
}  
 
 

I've tried to design the viewer on the pre-init event but without any sucess...

 

 

0
Steve
Telerik team
answered on 02 Mar 2010, 10:45 AM
Hello Antonio,

It seems your issue is different, if you are able to get the report data when exporting. Please take a look at the report viewer toolbar - does it show 1 out of x pages where x differs from 1? If so, then your pages are there, it is just the first page that appears to be empty.
Such scenarios are usually due to some content that cannot fit on the current page and is carried over to the next page. There are several cases when this happens:
  • Report Width is greater than than the available page space (Page Width - Left Margin - Right Margin).
  • There is a sub-report, which contains a report that is too wide, and while at design-time that is not obvious, at run-time it might cause the carry over to occur.
  • There is a report item with boundaries going out to the right from its parent section.
The background color of the item that is carried over to the next page is the same as the background of the report/sections, so the easiest way to spot the culprit is to set some more contrasting color.

Best wishes,
Steve
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Antonio Simoes
Top achievements
Rank 1
answered on 02 Mar 2010, 10:59 AM
Hello and thanks for the prompt assistance!

I solved my problem by adding a report viewer in design time to serve as a placeholder. Then I added multiple subreports and everything went just fine.

But, for reference, the toolbar was only showing 1 page (1 out of 1 pages). The 'next page' button was greyed out.
This problem was only happening when I tried to create the Report Viewer itself at runtime. If I added it - like I did later on - in design time the reports were being shown without a glitch.

Sincerely,

António Simões
0
Kevin
Top achievements
Rank 1
answered on 30 Jun 2010, 07:47 PM
Hi Steve,

I am having the same problem, I have a sub report in the first page and it is showed on the second page. Can you please let me know what would be the best approach to solve it? I am using Telerik Reporting 2009.3.1211 release.

Thanks for the help,
Kevin
0
Steve
Telerik team
answered on 02 Jul 2010, 04:46 PM
Hi Kevin,

Did you review the suggestions from my last post, namely:
  • Report Width is greater than than the available page space (Page Width - Left Margin - Right Margin).
  • There is a sub-report, which contains a report that is too wide, and while at design-time that is not obvious, at run-time it might cause the carry over to occur.
  • There is a report item with boundaries going out to the right from its parent section.

All the best,
Steve
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Kourosh
Top achievements
Rank 1
answered on 28 Apr 2019, 10:35 AM

Hi,

To remove the unwanted last empty page, put:

Height = 0

for all empty group footers.

It worked for me

BR
Kourosh

0
Neli
Telerik team
answered on 01 May 2019, 12:27 PM
Hello,

Please refer to the Problem: Telerik Reporting renders blank pages KB article to learn how to find which items or sections are causing the blank pages and/or spaces in the report. Actually these pages are not blank. Rather there is some content that cannot fit on the current page and is carried over to the next page.
 
Regards,
Neli
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
General Discussions
Asked by
Raghavan Subramanian
Top achievements
Rank 1
Answers by
Steve
Telerik team
David Purkey
Top achievements
Rank 1
Chavdar
Telerik team
Antonio Simoes
Top achievements
Rank 1
Kevin
Top achievements
Rank 1
Kourosh
Top achievements
Rank 1
Neli
Telerik team
Share this question
or