Page 1 of 1

reading list variables from code

Posted: Tue May 31, 2011 3:02 am
by Jozef Balga
Hi!
I am currently working on reports which use parameters set by external C# application, but first I need to get these parameters, their types and values. I use the following code

Code: Select all

Console.WriteLine("name " + report.Dictionary.Variables[param.name].Name);
Console.WriteLine("type " + report.Dictionary.Variables[param.name].Type);
Console.WriteLine("obj  " + report.Dictionary.Variables[param.name].ValueObject);
This works fine for primitive types but I am experiencing problems when reading list types (LongList, StringList), the ValueObject is null even when I set items in the Designer for that variable. How can I retrieve the items defined for these lists?

reading list variables from code

Posted: Tue May 31, 2011 8:48 am
by Alex K.
Hello,

You can use the following code:

Code: Select all

report.Dictionary.Variables["VariableName"].DialogInfo.GetDialogInfoItems(typeof(LongList));
Thank you.

reading list variables from code

Posted: Tue May 31, 2011 11:55 pm
by Jozef Balga
Thank you for the solution, it works perfectly.

reading list variables from code

Posted: Wed Jun 01, 2011 3:50 am
by Andrew
Great!

Have a nice day!

reading list variables from code

Posted: Thu Jun 02, 2011 2:11 am
by Jozef Balga
One more question: is it possible to get the variable list items defined as data columns? I explain: I have to do some filtering in SQL queries using the IN operator, so I need the values which can be passed to the query. The problem is, I need to get these items and then re-set them (removing some of them) before rendering the report. Thank you for your answer.

Jozef

reading list variables from code

Posted: Mon Jun 06, 2011 12:56 am
by Alex K.
Hello,

As a way, you can use the following code in Rendering event of report:

Code: Select all

List list = null;
StiVariable variable = this.Dictionary.Variables["Variable1"];
           
list = variable.DialogInfo.GetDialogInfoItems(typeof(IntList));
Thank you.