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

How to set design at runtime

3 Answers 181 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Martin
Top achievements
Rank 1
Martin asked on 09 Oct 2012, 07:01 AM
I successfully bound the datasource of the reportviewer, but the reportviewer itself isn't showing anything up. What am I missing?

var thisDataSet = SqlHelper.ExecuteDataset ( "Data Source=localhost;Initial Catalog=QmanagerDEV;User ID=sa;Password=secret", CommandType.StoredProcedure, "spQtask_SelectTaskBySimpleSearchToReport", SqlParameterList ( true ).ToArray () );
 
var objectDataSource = new Telerik.Reporting.ObjectDataSource();
objectDataSource.DataSource = thisDataSet;
 
Telerik.Reporting.Report report = new Report();
report.DataSource = objectDataSource;
 
Telerik.Reporting.InstanceReportSource reportSource = new InstanceReportSource();
reportSource.ReportDocument = report;
 
ReportViewer1.ReportSource = reportSource;
ReportViewer1.RefreshReport ();

I haven been trying to set the design of a Telerik ReportViewer, but not succeeded.
Is there a how-to somewhere, where I can see how to bind the design?

Thanks in advance,
Regards
 -Martin

3 Answers, 1 is accepted

Sort by
0
Martin
Top achievements
Rank 1
answered on 09 Oct 2012, 07:33 AM
I have just learned that the reportdesign is a class itself, it seems Microsofts "reportviewer"-ways of doing things have corrupted my soul and mind.

In the class I changed the code in the constructor to:
InitializeComponent ();
 
var thisDataSet = SqlHelper.ExecuteDataset ( "Data Source=localhost;Initial Catalog=QmanagerDEV;User ID=sa;Password=QMPassword", CommandType.StoredProcedure, "spQtask_SelectTaskBySimpleSearchToReport", SqlParameterList ( true ).ToArray () );
 
var objectDataSource = new Telerik.Reporting.ObjectDataSource ();
objectDataSource.DataSource = thisDataSet;
 
this.DataSource = objectDataSource;

And the design of my report is now showing up *Slow claps*.
However, the actual data is still not showing. I will update when I find a solution.

Regards
0
Martin
Top achievements
Rank 1
answered on 09 Oct 2012, 09:22 AM
Question
I have my code as follows, but the data is not displayed on the report.
var thisDataSet = SqlHelper.ExecuteDataset ( "Data Source=localhost;Initial Catalog=QmanagerDEV;User ID=sa;Password=secret", CommandType.StoredProcedure, "spQtask_SelectTaskBySimpleSearchToReport", SqlParameterList ( true ).ToArray () );
var objectDataSource = new Telerik.Reporting.ObjectDataSource ();
objectDataSource.DataSource = thisDataSet.Tables[0];
objectDataSource.CalculatedFields.Add ( new CalculatedField ( "ID" ) );
InstanceReportSource irs = new InstanceReportSource ();
irs.ReportDocument = this;
this.DataSource = objectDataSource;

I have the following fields in my dataset table:
T.ID,
T.Subject,
T.Description,
dbo.FormatDateTime(T.Created, 'DD-MM-YYYY') as Created,
Case When dbo.FormatDateTime(T.AcceptedDeadlineToDate, 'DD-MM-YYYY') = '01-01-1980' Then '' Else dbo.FormatDateTime(T.AcceptedDeadlineToDate, 'DD-MM-YYYY') End as Deadline,
T.ModuleCode,
ST.Name as StatusName,
TU.FirstName + ' ' + TU.LastName as CreatedByName,
TM.Name as ModuleName,
S.Number + ' ' + S.Name as ServiceName,
L.Name as LocationName,
C.Name as CustomerName,
A.Address1,
A.Address2,
A.ZipCode,
A.City

How do I bind this table with the fields to my report?
I have tried adding a datasource to the report and got the fields as shown in the attached picture, but when it binds nothing is shown.
I have checked whether the table held data, and it did.

I can't seem to figure out how it is done, plese help.
Regards
- Martin
0
Steve
Telerik team
answered on 11 Oct 2012, 02:50 PM
Hi Martin,

You should create an instance of your own report i.e. MyReport report = new MyReport() where MyReport is a report you have already created via the report designer and you have added TextBox items with appropriate Expressions. There is no AutoGenerateColumns feature in Telerik Reporting like with Grid controls, where you just provide data source to the grid and it automatically reflects the columns in your database and creates them automatically. The report is a template that you should create yourself (be it with the report designer or code). See Quickstart and Designing Reports help sections for more information.

Greetings,
Steve
the Telerik team

HAPPY WITH TELERIK REPORTING? Do you feel that it is fantastic? Or easy to use? Or better than Crystal Reports? Tell the world, and help fellow developers! Write a short review about Telerik Reporting and Telerik Report Designer in Visual Studio Gallery today!

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