Reporting displays empty page when creating it dynamically

12 posts, 1 answers
  1. Raghavan Subramanian
    Raghavan Subramanian avatar
    5 posts
    Member since:
    Aug 2009

    Posted 31 Oct 2009 Link to this post

    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

  2. Answer
    Steve
    Admin
    Steve avatar
    10941 posts

    Posted 02 Nov 2009 Link to this post

    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.
  3. David Purkey
    David Purkey avatar
    4 posts
    Member since:
    Nov 2009

    Posted 17 Nov 2009 Link to this post

    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


  4. Chavdar
    Admin
    Chavdar avatar
    898 posts

    Posted 18 Nov 2009 Link to this post

    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.
  5. David Purkey
    David Purkey avatar
    4 posts
    Member since:
    Nov 2009

    Posted 18 Nov 2009 Link to this post

    <%@ 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
  6. Antonio Simoes
    Antonio Simoes avatar
    7 posts
    Member since:
    Feb 2010

    Posted 01 Mar 2010 Link to this post

    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...

     

     

  7. Steve
    Admin
    Steve avatar
    10941 posts

    Posted 02 Mar 2010 Link to this post

    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.
  8. Antonio Simoes
    Antonio Simoes avatar
    7 posts
    Member since:
    Feb 2010

    Posted 02 Mar 2010 Link to this post

    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
  9. Kevin
    Kevin avatar
    4 posts
    Member since:
    Nov 2008

    Posted 30 Jun 2010 Link to this post

    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
  10. Steve
    Admin
    Steve avatar
    10941 posts

    Posted 02 Jul 2010 Link to this post

    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
  11. Kourosh
    Kourosh avatar
    19 posts
    Member since:
    May 2013

    Posted 28 Apr Link to this post

    Hi,

    To remove the unwanted last empty page, put:

    Height = 0

    for all empty group footers.

    It worked for me

    BR
    Kourosh

  12. Neli
    Admin
    Neli avatar
    48 posts

    Posted 01 May Link to this post

    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
Back to Top