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 web report receive values from the request — form input or query string — assigned by name before rendering.
Read form values and assign variables.
How it works. User input flows from the request into the report's variables, so the rendered document reflects exactly what was submitted.
Read form values and assign variables.
var report = new StiReport();
report.Load(StiNetCoreHelper.MapPath(this, "Reports/Variables.mrt"));
report.Compile();
var formValues = StiNetCoreViewer.GetFormValues(this);
report["Name"] = formValues["name"] ?? string.Empty;
report["Email"] = formValues["email"] ?? string.Empty;
report["Sex"] = formValues["sex"] != null && Convert.ToBoolean(formValues["sex"]);
return StiNetCoreViewer.GetReportResult(this, report);StiNetCoreViewer.GetFormValues(this)— the values posted from the page's form.- The indexer
report["Name"]writes report variables by name;Compile()prepares the report before values are set.
How it works. User input flows from the request into the report's variables, so the rendered document reflects exactly what was submitted.