Page 1 of 1

regarding accessing the number and names of the variables in .mrt files

Posted: Thu Nov 19, 2009 2:10 am
by AbdulAleem
Hi,

Can you give code how to find the number and names of the variable can be fetched from .mrt file.

My requirement is I want to create report dynamically and when I do so immediately I want to generate user interface to pass parameters to the report from aspx page.

Thanks
Abdul Aleem

regarding accessing the number and names of the variables in .mrt files

Posted: Thu Nov 19, 2009 5:25 am
by Edward
Hi Abdul,

You can add variables and categories in the following way:

Code: Select all

report.Dictionary.Variables.Add("MyCategory1");
if (report.Dictionary.Variables["MyVariable"] == null)
   report.Dictionary.Variables.Add(new StiVariable("Category2", "MyVariable", typeof(int), "1", false));

And there is a method to count all variables in the Dictionary:

Code: Select all

int variables=0;
foreach (StiVariable variable in report.Dictionary.Variables)
{
  if (!variable.IsCategory) variables++;
}
assigning of the variable is very simple too:

Code: Select all

report["MyVariable"] = 5;
Thank you.