Using Report Variables in Code
Our sample projects and report templates can help you learn the basics of working with our products.Report variables let a report receive values from the application — user input, settings, calculated data.
Passing values to variables. After loading and compiling the report, assign values through the report indexer using the variable names defined in the template:
Passing values to variables. After loading and compiling the report, assign values through the report indexer using the variable names defined in the template:
var report = new StiReport();
report.Load(@"..\Variables.mrt");
report.Compile();
report["Name"] = textBoxName.Text;
report["Surname"] = textBoxSurname.Text;
report["Email"] = textBoxEmail.Text;
report.Show();The indexer (report["Name"]) reads and writes report variables by name. Because values are assigned after Compile() and before rendering, the report is generated with exactly the data your application supplies.