Issue assigning datatable column to TextField when converting to use FlexReport

Posted by: dave.brown on 2 August 2019, 11:18 am EST

    • Post Options:
    • Link

    Posted 2 August 2019, 11:18 am EST

    This seems like a really simple issue but I’ve had no success in figuring it out.

    We’re converting from an older version of C1Reports to use FlexReports, and I’ve been going through and updating most of our code that was populating the report. Assigning regular text to a field is not an issue, assigning the datasource (retrieved from a service call and put into a datatable) is not an issue. However, when trying to assign a column from the datatable to a field in the Detail section of the report, I cannot get it to work. The old code, for the C1Report, looked like this:

    objdocument.Fields("fldItem").Text = "[ITEM_DESC]"
    

    The updated code I was trying to use looks like this:

    Dim newItemDescText As C1.Win.FlexReport.TextField = DirectCast(objdocument.Fields("fldItem"), C1.Win.FlexReport.TextField)
    newItemDescText.Text = "[ITEM_DESC]"
    

    If I leave the report field as a Field object, the code above works fine. When trying to be specific to the TextField object type, it does not. It just posts [ITEM_DESC] for as many rows that are in the datatable. I found another post on the forum where it was said to make sure to set the column name to the Text property of the TexTfield object, but I haven’t been able to find a code sample showing the format for doing that. Every FlexReport sample I find seems to use a datasource accessing the database directly, which is not an option for us.

    What am I doing wrong? Should I be using a different object type instead of the TextField? It looked like the Field object type was considered as a legacy type now, so I was trying to use something like the TextField object. Thanks for any help you can offer.

  • Posted 5 August 2019, 3:02 am EST

    Hello,

    You would need to set the TextField.Text property as follows:

    newItemDescText.Text = "=[ITEM_DESC]"
    
    

    This will set the appropriate values for the particular column, in each row.

    It has also been shown in the attached application.

    Regards,

    Esha

    FlexReport_DataTable_VB.zip

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels