0
votes

I have an RDLC report in VS 2013 that has two distinct sections. I'd like to show a footer only in the first section. To do this, I have a report variable called IsFirstSection that is set to "True". In my footer I have an if statement that displays text if this variable = "True".

Before the second section is displayed on the report I would like to set this variable to false. To do this, I have a function in the report custom code called SetVariableValue that takes a variable and a value and does just that. I have a text box before the second section that calls this function with Code.SetVariableValue(Variables!IsFirstSection, "False"). However, this code doesn't seem to be executing as IsFirstSection is still "True".

When I do this exact set up in an RDL report it works correctly. I even tried making a custom code function in the RDLC that just returns a string and when I call it from a text box expression nothing is displayed. How can I get the RDLC to run report custom code?

1

1 Answers

0
votes

A Report Variable seems a poor choice for this requirement. It's probably just chance that it appears to work under some conditions. Some quotes from the doco:

"By default, a report variable is calculated once ..."

"You cannot control when the report processor initializes a variable or evaluates an expression that updates a variable."

https://msdn.microsoft.com/en-us/dd255208.aspx

I would use a ReportItems reference instead. This would likely point at a textbox which presents field that changes value between "sections".