Looping Header Section

Posted by: yosef.teferi on 19 July 2023, 6:11 am EST

    • Post Options:
    • Link

    Posted 19 July 2023, 6:11 am EST

    I have 100 textboxes in the group header section of the report returned from the data reader and would like to check if the text box has value or not. I would like to display “-” on the textbox does not have any value displayed. Please help.

  • Posted 19 July 2023, 9:59 pm EST

    Hi Josie,

    You can handle the ‘GroupHeader_Format’ event to get the Text property of your TextBox(es). In the handler, you can check if the value is equal to an empty string you can then assign ‘-’ to your TextBox.

    Please find attached a sample implementing the same.

    Regards,

    Anand

    GroupHeader_Format.zip

  • Posted 19 July 2023, 11:53 pm EST

    thanks for providing the sample code. My case is a little bit different. I have over 20 text boxes in the group header section and will be tedious to check all of them like this for 20 text boxes. I would like to create a function that I can use for another report too if possible.

    if (this.textBox1.Text == “”)

    this.textBox1.Text = “-”;

    I was hoping to write a for each loop and check if the control is a textbox; if it is empty, then apply “-” for those textboxes with no value.

  • Posted 20 July 2023, 11:02 pm EST

    Hi Josie,

    In case you are having multiple TextBoxes you can use a foreach loop to iterate over all of the controls in your GroupHeader to check if they are a TextBox with a text of “” if yes you can replace it with “-”.

    Please find attached the updated sample for the same.

    Regards,

    Anand

    GroupHeader_Format_Updated.zip

Need extra support?

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

Learn More

Forum Channels