Connecting to Data from Code
Our sample projects and report templates can help you learn the basics of working with our products.A report's data can be supplied entirely from the controller instead of being stored in the template — clear the template connections and register a fresh dataset.
Load, clear connections, register data. In the
How it works. The report is assembled server-side on each request, so its data can come from anywhere the controller can reach.
Load, clear connections, register data. In the
GetReport action:var report = new StiReport();
report.Load(StiNetCoreHelper.MapPath(this, "Reports/TwoSimpleLists.mrt"));
report.Dictionary.Databases.Clear();
var data = new DataSet();
data.ReadXml(StiNetCoreHelper.MapPath(this, "Reports/Data/Demo.xml"));
report.RegData(data);
return StiNetCoreViewer.GetReportResult(this, report);Dictionary.Databases.Clear()— drop the connections baked into the template.RegData(data)— bind the code-suppliedDataSet; callDictionary.Synchronize()if the field structure changed.
How it works. The report is assembled server-side on each request, so its data can come from anywhere the controller can reach.