Formatting data fields

ljkljk
edited 11:26AM in FastReport .NET
How can I format text in a textbox according to numeric fields from database? For example: I've column of type Decimal(1,0). When the value is 0, text should be "Yes" and when the value is bigger than zero, text should be "No".

Comments

  • edited 11:26AM
    Hello,

    Write the following in your "Text" object:

    [[myTable.myColumn] == 0 ? "Yes" : "No"]
  • ljkljk
    edited 11:26AM
    AlexTZ wrote: »
    Hello,

    Write the following in your "Text" object:

    [[myTable.myColumn] == 0 ? "Yes" : "No"]

    Thanks for your answer. I did as you adviced and the result was an exception when previewing the report:

    Inner exception:
    Specified cast is not valid.

    And more specifically:
    at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
    at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
    at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
    at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
    at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
    at S2VbCxDU0OMTvjkNaW.EFY31DBgSwIavb22nW.Y9q9Ayr4g(Object[] )
    at 2EdewMbmqGQSEkKMRl.51f8d8EOnuaCgugUId.wdlCOWKl8(String , Variant )
    at FastReport.Report.Calc(String expression, Variant value)
    at FastReport.Report.Calc(String expression)
    at FastReport.TextObject.GetData()
    at FastReport.BandBase.GetData()
    at FastReport.Engine.ReportEngine.ApMEyuq4E(BandBase , Boolean )
    at FastReport.Engine.ReportEngine.M5Qjb8LLk(BandBase , Boolean )
    at FastReport.Engine.ReportEngine.K51njN4eH(BandBase , Boolean )
    at FastReport.Engine.ReportEngine.Avx9GWUhwW()
    at FastReport.Engine.ReportEngine.JI19ViETCm(ReportPage )
    at FastReport.Engine.ReportEngine.anE9t8f1nJ()
    at FastReport.Engine.ReportEngine.dUfCsgb7K(Boolean , Boolean , ReportPage )
    at FastReport.Report.Prepare(Boolean append)
    at FastReport.Report.Show()
    at PsPqgNVwHXMHeJbrIU6.eju36EVXM0ZflSjWsny.99FjXl1OC()

    Any idea what's wrong?
  • edited 11:26AM
    I've tried to create a MS SQL data table with Decimal(1,0) column. It works just fine for me. If you have a demo for this error, you can send it to my email: tz@fast-report.com

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.