Page 1 of 2

Report on DataTable

Posted: Thu Feb 17, 2011 12:11 pm
by jay@bplogix.com
I have a DataTable in C# ... can I run a report using that DataTable as "input" to the report?

Report on DataTable

Posted: Thu Feb 17, 2011 2:56 pm
by jay@bplogix.com
Basically, here is the code I tried:

StiReport report = new StiReport();
DataTable dTable = new DataTable("Data");
dTable.Columns.Add("col1", typeof(string));
DataRow drow = dTable.NewRow();
drow["col1"] = "test1";
drow = dTable.NewRow();
drow["col1"] = "test2";
report.RegData(dTable);
report.Dictionary.Synchronize();
StiWebDesigner1.Design(report);

... when I enter design mode, add a data band, add the col1 to the databand, and then hit preview ... the report shows nothing!
Also, under Data sources in design mode the "Data" datasource has an icon with a small black X at the bottom.

Is this supposed to work?

Report on DataTable

Posted: Fri Feb 18, 2011 1:24 am
by Alex K.
Hello,

Please send us a sample project with data which reproduses the problem.

Thank you.

Report on DataTable

Posted: Fri Feb 18, 2011 2:12 pm
by jay@bplogix.com
Attached is a complete ASP.NET Web Site (no project file ... just use Open->Web Site).

This sample has the latest pre-release DLLs in the Bin folder ... but I tried the 2010 version with same results.

Basically when I run the report, I see no rows in the Data section (there should be 2).

Thanks!

Report on DataTable

Posted: Mon Feb 21, 2011 1:45 am
by Alex K.
Hello,

Please check the following code:

Code: Select all

...
DataRow drow = dTable.NewRow();
drow["col1"] = "test1";
drow["col2"] = 1;
dTable.Rows.Add(drow);
drow = dTable.NewRow();
drow["col1"] = "test2";
drow["col2"] = 2;
dTable.Rows.Add(drow);
report.RegData(dTable);
...
Thank you.

Report on DataTable

Posted: Tue Feb 22, 2011 2:00 pm
by jay@bplogix.com
Ahhh!!! Thanks!!! Dumb mistake on my part.

Report on DataTable

Posted: Tue Feb 22, 2011 11:44 pm
by Andrew
No problems! Let us know if you have additional questions.

Report on DataTable

Posted: Wed Feb 23, 2011 4:19 pm
by jay@bplogix.com
Does this same technique work for the Preview tab when designing a report? I took that same project, added:

and
StiWebDesigner1.Design(report);
but the Preview mode does not show the records from the DataTable. Is there a callback or something to populate the data when in preview mode of the designer?

Thanks!

Report on DataTable

Posted: Thu Feb 24, 2011 1:27 am
by Alex K.
Hello,

For a web designer to view the report in preview, you must implement the GetPreviewDataSet event, where you need to get the data and pass them to the DataSet.

Thank you.

Report on DataTable

Posted: Thu Feb 24, 2011 3:37 pm
by jay@bplogix.com
I added
StiWebDesigner1.GetPreviewDataSet += new StiWebDesigner.StiPreviewDataSetEventHandler(StiWebDesigner1_GetPreviewDataSet);

and

protected void StiWebDesigner1_GetPreviewDataSet(object sender, StiWebDesigner.StiPreviewDataSetEventArgs e)
{
// This is never hit!
}

but my StiWebDesigner1_GetPreviewDataSet is never called even when I hit preview. Am I registering it correctly?

thx!