Setting parameters in the dictionary from code

Stimulsoft Reports.WEB discussion
Post Reply
Siira
Posts: 17
Joined: Tue Jun 15, 2010 8:07 am
Location: Netherlands

Setting parameters in the dictionary from code

Post 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?
Vladimir
Posts: 1462
Joined: Fri Apr 13, 2007 4:05 am
Location: Earth

Setting parameters in the dictionary from code

Post 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.
Siira
Posts: 17
Joined: Tue Jun 15, 2010 8:07 am
Location: Netherlands

Setting parameters in the dictionary from code

Post by Siira »

Thank you very much. That did the trick, now it works perfectly! :)
Andrew
Posts: 4108
Joined: Fri Jun 09, 2006 3:58 am

Setting parameters in the dictionary from code

Post by Andrew »

Perfect!!!
Post Reply