Using Switch Statement Causing Error

  • Using the following in a text box on a local report included in a VS 2010 c# project:

    = Switch(

    Fields!BeneficiaryType="PERSON","Name:",

    Fields!BeneficiaryType = "TRUST","Trust Name:",

    Fields!BeneficiaryType = "Charity","Charity/Organization:",

    Fields!BeneficiaryType = "ESTATE","Estate Name:")

    Getting the following compile error when trying to compile the project.

    Error1The Value expression for the textrun ‘PrimaryLabel1.Paragraphs[0].TextRuns[0]’ contains an error: [BC30518] Overload resolution failed because no accessible '=' can be called with these arguments:

    'Public Shared Operator =(a As String, b As String) As Boolean': Value of type 'Microsoft.ReportingServices.ReportProcessing.ReportObjectModel.Field' cannot be converted to 'String'.C:\Development\BDM\BDMViewer\BDMViewer\Reports\rptEmployeeDetails.rdlc

    Shouldn't this work?

  • jean.gelinas (11/8/2011)


    Using the following in a text box on a local report included in a VS 2010 c# project:

    = Switch(

    Fields!BeneficiaryType="PERSON","Name:",

    Fields!BeneficiaryType = "TRUST","Trust Name:",

    Fields!BeneficiaryType = "Charity","Charity/Organization:",

    Fields!BeneficiaryType = "ESTATE","Estate Name:")

    Getting the following compile error when trying to compile the project.

    Error1The Value expression for the textrun ‘PrimaryLabel1.Paragraphs[0].TextRuns[0]’ contains an error: [BC30518] Overload resolution failed because no accessible '=' can be called with these arguments:

    'Public Shared Operator =(a As String, b As String) As Boolean': Value of type 'Microsoft.ReportingServices.ReportProcessing.ReportObjectModel.Field' cannot be converted to 'String'.C:\Development\BDM\BDMViewer\BDMViewer\Reports\rptEmployeeDetails.rdlc

    Shouldn't this work?

    I may be mistaken, but I believe the ".Value" part in your reference to the field objects are missing.

  • Duh...

    Add .Value to each field call ...

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply