问题
I am trying to make a comparatively complex rdlc report for my web application and the problem that I am currently facing is that there is one function defined in the custom code section of the report. And then I added another function there and the report is not executing giving an error "The definition of report is invalid." Everytime I remove this function the report runs smoothly, when I add it back it gives this error in the report viewer.
回答1:
For writing custom code in rdlc :
- On the Report menu, click Report Properties.
- On the References tab, click the add button and then select or browse to the assembly from the Add Reference dialog box.
- In Classes, type name of the class and provide an instance name to use within the report. That's in the case of instance members, in the case of static (shared in VB) members, you don't need to add anything in Classes.
In Custom Code You can Write your functions:
Public ReadOnly Property FetchSomeData() As String
Get
Return sharedMember
End Get
End Property
Dim sharedMember As String = "Shared Data (Does not require initialization)"
Public Function MyFunction(ByVal s As String)
'' Write your code and return String
Return s.toUpper()
End Function
来源:https://stackoverflow.com/questions/29537886/adding-multiple-functions-to-rdlc-custom-code