Report on DataTable

Stimulsoft Reports.WEB discussion
jay@bplogix.com
Posts: 251
Joined: Fri Feb 04, 2011 11:46 am
Location: San Diego, CA

Report on DataTable

Post by jay@bplogix.com »

I have a DataTable in C# ... can I run a report using that DataTable as "input" to the report?
jay@bplogix.com
Posts: 251
Joined: Fri Feb 04, 2011 11:46 am
Location: San Diego, CA

Report on DataTable

Post 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?
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Report on DataTable

Post by Alex K. »

Hello,

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

Thank you.
jay@bplogix.com
Posts: 251
Joined: Fri Feb 04, 2011 11:46 am
Location: San Diego, CA

Report on DataTable

Post 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!
Attachments
830.Stimulsoft.zip
(7.46 MiB) Downloaded 268 times
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Report on DataTable

Post 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.
jay@bplogix.com
Posts: 251
Joined: Fri Feb 04, 2011 11:46 am
Location: San Diego, CA

Report on DataTable

Post by jay@bplogix.com »

Ahhh!!! Thanks!!! Dumb mistake on my part.
Andrew
Posts: 4108
Joined: Fri Jun 09, 2006 3:58 am

Report on DataTable

Post by Andrew »

No problems! Let us know if you have additional questions.
jay@bplogix.com
Posts: 251
Joined: Fri Feb 04, 2011 11:46 am
Location: San Diego, CA

Report on DataTable

Post 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!
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Report on DataTable

Post 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.
jay@bplogix.com
Posts: 251
Joined: Fri Feb 04, 2011 11:46 am
Location: San Diego, CA

Report on DataTable

Post 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!
Post Reply