Adding multiple functions to RDLC custom code

2019-08-10 16:12发布

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条回答
Lonely孤独者°
2楼-- · 2019-08-10 16:46

For writing custom code in rdlc :

  1. On the Report menu, click Report Properties.
  2. On the References tab, click the add button and then select or browse to the assembly from the Add Reference dialog box.
  3. 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
查看更多
登录 后发表回答