Dynamic report using crystal reports / send parameters to crystal report

  1. #1

    Dynamic report using crystal reports / send parameters to crystal report

    I managed to finally include a Crystal Report in a page using the code posted by Daniil in reply #5 in this thread.
    However, I could only do this in the Page_Load event of the page. I couldn't get the same functionality if I put the same code in the Click DirectEvent of a button. Am I missing something there?
    This code works in the Page_Load event, but not a Click DirectEvent:
    panReport.AutoLoad.Mode = Ext.Net.LoadMode.IFrame;
    panReport.AutoLoad.Url = "testReport.aspx";
    //panReport.Reload(); // EDIT: it is not necessary to reload here. The report will still be rendered.
    Also, is it possible to send some parameters to this report? The user should be able to select i.e. a city from a combobox and then click a button to filter the results.

    Thanks in advance.
  2. #2
    Hi,

    Please look at the example how to load an iframe during a DirectEvent.
    https://examples1.ext.net/#/Panel/Basic/AutoLoad/

    To send parameters please use the AutoLoad's Params.
  3. #3
    Hello, Daniil.
    Sorry for the late response.
    This worked great. Had some issues getting the value on target page, but looked here and this helped.

    3. To get that params on server-side use: this.Request["paramname"]
    Thanks!

    This is the final result, for someone looking for something similar:

    1.- Use a ext:Panel in MyReport.aspx
    <ext:Panel runat="server" Height="400px" Width="900px" ID="panReport"></ext:Panel>
    2.- In Report.aspx.cs:
    Ext.Net.Parameter myParam= new Ext.Net.Parameter("parName", "parValue",Ext.Net.ParameterMode.Raw);
    panReport.AutoLoad.Mode = Ext.Net.LoadMode.IFrame;
    panReport.AutoLoad.Url = "reports.aspx";
    panReport.AutoLoad.Params.Add(myParam);
    panReport.LoadContent();
    3.- In reports.aspx:
    <CR:CrystalReportViewer ID="CRreport" runat="server" AutoDataBind="true" ToolPanelView="None" />
    4.- In reports.aspx.cs:
    string idOficina = this.Request["parName"]; // gets your parameter
    
    // And next, I have some code to fill in a DataTable
    Mark as closed.
  4. #4
    Thanks for the update and sharing the solution, it really can help someone in the future.

Similar Threads

  1. Crystal Report and Ext.net
    By sonlas7y20 in forum 1.x Help
    Replies: 7
    Last Post: Dec 29, 2011, 2:27 PM
  2. Crystal Report Viewer is not showing?
    By sadeque in forum 1.x Help
    Replies: 6
    Last Post: Nov 10, 2011, 3:43 PM
  3. [CLOSED] Crystal Report page Count?
    By Vasudhaika in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Nov 23, 2010, 9:02 AM
  4. Crystal Report Viewer Overlap
    By EzaBlade in forum 1.x Help
    Replies: 0
    Last Post: Sep 23, 2009, 1:26 PM
  5. How to add crystal report within panel
    By sadeque in forum 1.x Help
    Replies: 4
    Last Post: Jul 28, 2009, 5:57 AM

Tags for this Thread

Posting Permissions