Saving the current status of the report

  Previous topic Next topic JavaScript is required for the print function Mail us feedback on this topic! Mail us feedback on this topic!  

The following sample code shows you how to execute a report and save its status into a saved report. You will need to create an ASCX user control where you place the CMSReporting\DisplayReport.ascx user control with ID set to displayReportControl. The code behind will look like this:

 

[C#]

 

using System.Data;

 

protected void Page_Load(object sender, EventArgs e)

{

    

        // Create a new data table with parameters

        DataTable dtp = new DataTable();

        dtp.Columns.Add("ModifiedSince"typeof(DateTime));

 

        object[] parameters = new object[1];

        parameters[0] = new DateTime(2010, 1, 1);

 

        dtp.Rows.Add(parameters);

 

        // Disable loading parameters from basic form 

        displayReportControl.LoadFormParameters = false;

 

        // Choose a report to save by code name

        displayReportControl.ReportName = "RecentlyModifiedDocuments";

        

        // Set custom parameters

        displayReportControl.ReportParameters = dtp.Rows[0];

        

        // Reload data with new parameters

        displayReportControl.ReloadData(false);

        

        // SaveReport() returns 0 if some problem occurred or

        // SavedReportID of the successfully saved report 

        displayReportControl.SaveReport();

}

 

// This override must be added if the report contains a table to avoid getting the "...must be placed inside a 

// form tag with runat=server" error

public override void VerifyRenderingInServerForm(Control control)

{

        return;

}

 

Page url: http://devnet.kentico.com/docs/5_5r2/devguide/index.html?api_saving_current_status_of_the_report.htm