Conditionally Remove Page

Posted by: sean.grebey on 10 September 2018, 2:14 am EST

    • Post Options:
    • Link

    Posted 10 September 2018, 2:14 am EST

    I have an overflow page for data at the end of a report. If there is no overflow data they want me to hide the final page. I’m trying to figure out how to do that. I was hoping maybe there was just some kind of Page Collection where I could delete the last one out of it? Or could I maybe hide all the components manually? I don’t want a blank empty page either.

  • Posted 12 September 2018, 11:20 pm EST

    Hi Sean,

    We apologize for the delayed response.

    You may remove pages from Report using C1PrintDocument object pages property which can be access while the report is loaded InMemory as following demo:

    https://demos.componentone.com/aspnet/ControlExplorer/C1ReportViewer/InMemoryDocuments.aspx

    To remove pages, please use the following code snippet within makeDoc method:

    C1PrintDocument doc = report.C1Document;
                for (int i = doc.Pages.Count-1; i > 0; i--)
                {
                    if (i > 1) {
                        doc.Pages.RemoveAt(i);
                    }
                }
    

    Please refer to the attached sample for reference.

    ~Manish

    C1ReportViewer_Page_Remove.zip

Need extra support?

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

Learn More

Forum Channels