Reports are usually bound to data at design time, but you can also supply the data entirely from code.

Registering data. Load the report template, clear any design-time connections, and register your own data source under a name that matches the data references in the template:
private void ShowReport(DataSet dataSet)
{
    var report = new StiReport();
    report.Load(@"Reports\TwoSimpleLists.mrt");
    report.Dictionary.Databases.Clear();
    report.RegData("Demo", dataSet);
    report.Show();
}

The data itself can come from anywhere — here it is read from an XML file and its schema:
var dataSet = new DataSet();
dataSet.ReadXmlSchema(@"Data\Demo.xsd");
dataSet.ReadXml(@"Data\Demo.xml");
ShowReport(dataSet);

RegData makes the object available to the report engine; Dictionary.Databases.Clear() removes the connections stored in the template so that only your run-time data is used.

By using this website, you agree to the use of cookies for analytics and personalized content. Cookies store useful information on your computer to help us improve efficiency and usability. For more information, please read the privacy policy and cookie policy.