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

Blank Report after Q3 2009 Upgrade

5 Answers 47 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Valerie
Top achievements
Rank 1
Valerie asked on 15 May 2010, 01:32 AM

I have several reports that are built dynamically that stopped working after we upgraded to the Q3 2009 release, using version 3.2.9.1211. I tried setting the ReportViewer's EnableViewState property to false and that had no impact on the problem. When the report is generated a 1-page blank report appears.

 

I took one of the Telerik sample provided on this forum and put it in a small, much simpler project. I receive the exact sample behavior. Here is the code that I am using:

 

using

 

System;

 

 

 

using

 

System.Web;

 

 

 

using

 

System.Web.UI;

 

 

 

using

 

System.Web.UI.WebControls;

 

 

 

using

 

System.Data;

 

 

 

using

 

System.Configuration;

 

 

 

using

 

System.Web.Security;

 

 

 

using

 

System.Web.UI.WebControls.WebParts;

 

 

 

using

 

System.Web.UI.HtmlControls;

 

 

 

using

 

Telerik.Web.UI;

 

 

 

using

 

Telerik.Reporting;

 

 

 

using

 

Telerik.Reporting.Drawing;

 

 

 

public

 

partial class Default : System.Web.UI.Page

 

{

 

protected void Page_Load(object sender, EventArgs e)

 

{

Telerik.Reporting.

Report rpt = new Telerik.Reporting.Report();

 

 

DataSet ds = new DataSet();

 

ds.Tables.Add();

 

DataTable table = ds.Tables[0];

 

 

int columnCount = 3;

 

 

int rowCount = 1000;

 

 

//Add columns

 

 

 

 

 

for (int column = 0; column <= columnCount - 1; column++)

 

{

table.Columns.Add(

"Column" + (column + 1).ToString(), typeof(string));

 

}

 

//Add rows

 

 

 

 

 

for (int row = 0; row <= (rowCount - 1); row++)

 

{

 

string[] rowVals = (string[])Array.CreateInstance(typeof(string), columnCount);

 

 

DataRowCollection rowCollection = table.Rows;

 

 

for (int column = 0; column <= columnCount - 1; column++)

 

{

rowVals[column] =

"value_" + (column + 1).ToString() + "_" + (row + 1).ToString();

 

}

table.Rows.Add(rowVals);

}

rptViewer.Report = GenerateReportDefinition(

ref ds);

 

rptViewer.RefreshReport();

}

 

private Telerik.Reporting.TextBox CreateTxtHeader(string FieldName, int i)

 

{

Telerik.Reporting.

TextBox txtHead = new Telerik.Reporting.TextBox();

 

txtHead.Value = FieldName;

 

return txtHead;

 

}

 

private Telerik.Reporting.TextBox CreateTxtDetail(string FieldName, int i)

 

{

Telerik.Reporting.

TextBox txtHead = new Telerik.Reporting.TextBox();

 

txtHead.Value =

"=[" + FieldName + "]";

 

 

return txtHead;

 

}

Telerik.Reporting.

Report GenerateReportDefinition(ref System.Data.DataSet dataSource)

 

{

Telerik.Reporting.

Report report1 = new Telerik.Reporting.Report();

 

report1.DataSource = dataSource;

 

int count = dataSource.Tables[0].Columns.Count - 1;

 

Telerik.Reporting.Drawing.

Unit x = Telerik.Reporting.Drawing.Unit.Inch(0);

 

Telerik.Reporting.Drawing.

Unit y = Telerik.Reporting.Drawing.Unit.Inch(0);

 

 

SizeU size = new SizeU(Telerik.Reporting.Drawing.Unit.Cm(2), Telerik.Reporting.Drawing.Unit.Inch(0.3));

 

Telerik.Reporting.

ReportItemBase[] headColumnList = new Telerik.Reporting.ReportItem[count];

 

Telerik.Reporting.

ReportItemBase[] detailColumnList = new Telerik.Reporting.ReportItem[count];

 

 

for (int column = 0; column < count; column++)

 

{

 

string columnName = dataSource.Tables[0].Columns[column].ColumnName;

 

Telerik.Reporting.

TextBox header = this.CreateTxtHeader(columnName, column);

 

header.Location =

new Telerik.Reporting.Drawing.PointU(x, y);

 

header.Size = size;

headColumnList[column] = header;

Telerik.Reporting.

TextBox textBox = this.CreateTxtDetail(columnName, column);

 

textBox.Location =

new Telerik.Reporting.Drawing.PointU(x, y);

 

textBox.Size = size;

detailColumnList[column] = textBox;

x += Telerik.Reporting.Drawing.

Unit.Inch(1);

 

}

Telerik.Reporting.

ReportHeaderSection reportHeaderSection1 = new Telerik.Reporting.ReportHeaderSection();

 

reportHeaderSection1.Height =

new Telerik.Reporting.Drawing.Unit(0.3, Telerik.Reporting.Drawing.UnitType.Inch);

 

 

//reportHeaderSection1.Style.BackgroundColor = Color.LightGray;

 

 

 

 

reportHeaderSection1.Items.AddRange(headColumnList);

Telerik.Reporting.

DetailSection detailSection1 = new Telerik.Reporting.DetailSection();

 

detailSection1.Height =

new Telerik.Reporting.Drawing.Unit(0.3, Telerik.Reporting.Drawing.UnitType.Inch);

 

detailSection1.Items.AddRange(detailColumnList);

report1.Items.Add(reportHeaderSection1);

report1.Items.Add(detailSection1);

 

return report1;

 

}

}

5 Answers, 1 is accepted

Sort by
0
Valerie
Top achievements
Rank 1
answered on 15 May 2010, 07:24 AM
I believe that the code that creates the Report Items and Sections needs to be moved. I modified the code by creating a class called Report1 that was just a wrapper around the Telerik.Reporting.Report class. In the constructor, I create the report items and sections. When I did this, the code worked.

Odd because this code worked before the upgrade. Is this the best way to address this issue?

Thanks.

PS, there is a minor issue in the Telerik code in the second loop. Condition should be same as first for loop.
0
Valerie
Top achievements
Rank 1
answered on 16 May 2010, 05:30 AM

That solution won't work for me because the ReportViewer requires a constructor with no parameters, so I am back to square one.

Where should the report definition be modified?

 

Thanks.

0
Valerie
Top achievements
Rank 1
answered on 16 May 2010, 06:47 AM
I turned on the debugger and it appears that the report constructor code is executed twice - first when the report object is instantiated and second by the ReportViewer control. The second time it is executed, the ReportItems no longer exist. This is also the call that is requiring a constructor with no parameters.

How can I make this behavior not happen? This was not happening before this upgrade and it is getting quite frustrating. I have downloaded several samples that create programatic reports that I have found on the forum and in knowledge base articles and none of them work. The Reporting online documentation provides examples of how to create the report objects but makes no mention of where to put the code to get it to actually work.
0
Peter
Telerik team
answered on 20 May 2010, 11:39 AM
Hi Valerie,

If you use the designer to create the report -  all code is placed in the InitializeComponent() method. Š¢herefore the best way to learn how to generate the report is by looking at the auto-generated code

If you are still having problems and since we do not know what is your exact goal, providing us with a runnable sample in a support ticket would be the best way to proceed.

Kind regards,
Peter
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
Valerie
Top achievements
Rank 1
answered on 26 May 2010, 01:17 AM

I created a ticket. For some reason, I did not receive an email when you replied.

 

This code all worked before the upgrade. Even the Telerik sample code for creating dynamic reports does not work with the ReportViewer. It does export to PDF.

Tags
General Discussions
Asked by
Valerie
Top achievements
Rank 1
Answers by
Valerie
Top achievements
Rank 1
Peter
Telerik team
Share this question
or