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 swapped at run time: clone the report, clear its template connections and register a fresh dataset.
Replace the data.
How it works. The report is re-rendered against code-supplied data, so one template can present entirely different datasets on demand.
Replace the data.
var report = Report.Clone() as StiReport;
report.Dictionary.Databases.Clear();
var data = new DataSet();
data.ReadXml(await Http.GetStreamAsync("Data/Demo1.xml"));
report.RegData(data);
report.Dictionary.Synchronize();
report.Render();
Report = report;
StateHasChanged();Clone()— work on a copy so the original template is untouched.Dictionary.Databases.Clear()+RegData+Synchronize()— drop the template's connections and bind the new data.StateHasChanged()— re-render the Razor page so the viewer shows the updated report.
How it works. The report is re-rendered against code-supplied data, so one template can present entirely different datasets on demand.