Page 1 of 1

Setting parameters in the dictionary from code

Posted: Fri Jun 25, 2010 2:57 am
by Siira
I'm using the variables and "Request from user" feature to allow the user to set a view variables which I then use in my queries.

As some of them are actually retreived from elsewhere in the system I would like to control them in the codebehind on the aspx page. I have been trying for a while, but haven't been able to get it to work. I have set a default value in the variable in the report itself and everytime I open the page, the report is loaded with the default value of the variable, thus ignoring my line to set it.

These are the lines of code I use in my report:
(StiWebReport1 is on the aspx and a report is loaded, StiWebViewerFx1 is also on the aspx)

Code: Select all

StiWebViewerFx1.Report = StiWebReport1.GetReport();
StiWebViewerFx1.Report.Dictionary.Variables["ParentVendorID"] = new Stimulsoft.Report.Dictionary.StiVariable("ParentVendorID", 33);
StiWebViewerFx1.DataBind();
What am I doing wrong here?

Setting parameters in the dictionary from code

Posted: Fri Jun 25, 2010 7:54 am
by Vladimir
Hello,

All actions with a report should be done before assigning it to the viewer:

Code: Select all

StiReport report = StiWebReport1.GetReport();
report.Dictionary.Variables["ParentVendorID"] = new Stimulsoft.Report.Dictionary.StiVariable("ParentVendorID", 33);
StiWebViewerFx1.Report = report;
Thank you.

Setting parameters in the dictionary from code

Posted: Mon Jun 28, 2010 3:15 am
by Siira
Thank you very much. That did the trick, now it works perfectly! :)

Setting parameters in the dictionary from code

Posted: Mon Jun 28, 2010 5:36 am
by Andrew
Perfect!!!