Report Design
 Crystal Reports Forum : Crystal Reports for Visual Studio 2005 and Newer : Report Design
Message Icon Topic: Next page button not always working Post Reply Post New Topic
<< Prev Page  of 4 Next >>
Author Message
Scott S
Newbie
Newbie


Joined: 08 Jan 2009
Online Status: Offline
Posts: 1
Quote Scott S Replybullet Posted: 08 Jan 2009 at 11:37am

What if you can not move all the code?  What specifically should be in the init?

I have three classes that are used to create one report so all the code in eacxh class can not be moved to the various init's.

Thanks

 
Scott
IP IP Logged
jijogeorge
Newbie
Newbie
Avatar

Joined: 11 Nov 2008
Online Status: Offline
Posts: 5
Quote jijogeorge Replybullet Posted: 11 Feb 2009 at 10:54pm
Hi,

I have one crystal report and m using crystal report viewer to display the report. The same report viewer is used to display other reports also, based on the report type selected by the user.
I have placed the report viewer inside a div and set the scroll properties

<td align="center" bgcolor="#FFFFFF" style="height: 415px;" colspan="4">
                            <div id="container" style="overflow: auto; width:100%;" >
                                <CR:CrystalReportViewer ID="iTocReport" runat="server" AutoDataBind="True"  ShowAllPageIds="True" Width = "100%" />   
                            </div>
                        </td>

The report works fine in Mizilla, the reports comes inside the div, and the div has scroll bars. The same report is not working proper in IE, the report going out of the div and looks ugly..

Can anyone suggest a solution for this?



Thatks in advance.
Jijo George
Software Engineer,
Bangalore, India
IP IP Logged
kuldeep_sss
Newbie
Newbie
Avatar

Joined: 24 Mar 2009
Location: India
Online Status: Offline
Posts: 3
Quote kuldeep_sss Replybullet Posted: 24 Mar 2009 at 7:01pm
I am having problem with the next page button of the crystal report viewer, whenever i click on it, the page goes blank. I have a page where user selects a type of Table to be used, based upon this selection, a dropdownlist shows the entries for which report can be generated. On clicking the submit button report is generated and upto this place all works fine.  Whenevr i click on the next page button or any other button on the report viewer, the page goes blank, and if made the same search again, the next page in the report is shown.
    I have read about placing the code in Page_Init(), but as i make the data connection and the query based on the input of the user, will it help? How can i initialize the report document when it has to be generated based upon the user's choice? I am in a kind of fix.

Can anyone have a solution to it?

Thanks


Edited by kuldeep_sss - 24 Mar 2009 at 7:17pm
Kuldeep Singh
IP IP Logged
jijogeorge
Newbie
Newbie
Avatar

Joined: 11 Nov 2008
Online Status: Offline
Posts: 5
Quote jijogeorge Replybullet Posted: 24 Mar 2009 at 9:26pm
Hi,
I also faced the same issue. but it rectified when i  shifted the code, to display the selected report, to page_init event. You can do the the formatting of reports in the page_load event. Check whether the enableviewstate (in .Net, actally you didn't mention your code behind language)property of report viewer and set it to true. Then i hope your problem will be rectified.
 
Jijo George
Software Engineer,
Bangalore, India
IP IP Logged
kuldeep_sss
Newbie
Newbie
Avatar

Joined: 24 Mar 2009
Location: India
Online Status: Offline
Posts: 3
Quote kuldeep_sss Replybullet Posted: 25 Mar 2009 at 10:56am
The page_Init() method was not working properly in my case. May be because the report source is defined after the selection of the tables. I am using VB as the code language. I have solved this issue by using Session(). In the Page_Load() method i have checked if it is a postback or not. If it is a postback, the take the session() element of the report and assign it to the viewer.

Thanks for the help.

Kuldeep Singh
IP IP Logged
manpakhong
Newbie
Newbie


Joined: 27 Mar 2009
Location: Hong Kong
Online Status: Offline
Posts: 1
Quote manpakhong Replybullet Posted: 27 Mar 2009 at 1:27am

Problem: Crystal Report has issue a demonistration code to show that how to display Crystal Report embedded in ASP.NET web page. However, programmers always
confront problem that the code only display two page with the netvigator button. It cannot go beyond page if the report has.
 
The main problem of this issue is that we always commit the wrong concept that we place the Report loading code over the Page_Load() instead of
Page_Init()

Two Main Points to solve the problem:
1. Load crytal report at Page_Init() instead of Page_Load()
2. Use Session in Page to store the report at Server, and load it back when Page is not postback

The Correct version:

protected void Page_Init(object sender, EventArgs e)
{
    if (!IsPostBack)
    {

    }
    else
    {
        mb_objcryRptDoc = (ReportDocument)Session["rptDoc"];   <-------------------------------------------------------Restore the report from Session for overcome the
                                                                                                         -------------------------------------------------------Page beyond page 3 problem.

    } // end if ... else (!IsPostBack)

    // ------------------------------------------------
    mb_fnInitFillAll();   <------------------------------------------------------ I load crystal report at this method

}

// #############
// # Page Load #
// #############
protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
        FS = FORM_STATE.INIT;
        ViewState.Add("FS", FS);
        mb_fnSetFormState(FS);

    }
    else
    {
        FS = (FORM_STATE)ViewState["FS"];
        mb_fnSetFormState(FS);

    } // end if ... else (!IsPostBack)

    // ------------------------------------------------
    // code to check user Login
    mb_objUserSession = new UserSession();

    if (!mb_objUserSession.pUser_Login)
    {
        Page.Response.Redirect("./frmUserNotPermitted.html");
    } // end if (!mb_objUserSession.pUser_Login)

    // code to check user permissions
    mb_fnCheckPermissions();
} // end Page_Load(object sender, EventArgs e)        

// #############
// #############                 

    /* *
     * method to init and fill all
     * */
    private void mb_fnInitFillAll()
    {
        mb_fnInit();

        // for user authentication
        mb_fnInitUserObject(); // vwrUserObject
        mb_fnInitUserGroupObject(); // vwrUserGroupObject

        if (Request.QueryString["Quotation_IDP"] != null && Request.QueryString["Quotation_IDN"] != null &&
            Request.QueryString["Quotation_IDR"] != null)
        {
            txtQuotation_IDP.Text = Request.QueryString["Quotation_IDP"].ToString();
            txtQuotation_IDN.Text = Request.QueryString["Quotation_IDN"].ToString();
            txtQuotation_IDR.Text = Request.QueryString["Quotation_IDR"].ToString();
            cbQuotation_ID.Checked = true;
            cbQuotation_ID.Enabled = false;
        }

        string strQueryString = "";

        if (Request.QueryString["URL"] != null)
        {
            strQueryString = Request.QueryString["URL"] + "?Quotation_IDP=" + txtQuotation_IDP.Text +
                "&Quotation_IDN=" + txtQuotation_IDN.Text +
                "&Quotation_IDR=" + txtQuotation_IDR.Text;
        } // end if (Request.QueryString["URL"] != null)

        if (Request.QueryString["URL2"] != null)
        {
            strQueryString += "&" + Request.QueryString["URL2"].ToString();
        } // end if (Request.QueryString["URL2"] != null)

        if (Request.QueryString["URL3"] != null)
        {
            strQueryString += "&" + Request.QueryString["URL3"].ToString();
        } // end if (Request.QueryString["URL3"] != null)

        this.hplBacktoQuotation.NavigateUrl=strQueryString;

        if (Request.QueryString["URL"] != null)
        {
            if (Request.QueryString["URL"].ToString().CompareTo("frmQuotationCMgt.aspx") == 0 ||
                Request.QueryString["URL"].ToString().CompareTo("frmrptQuotationC.aspx") == 0 )
            {
                txtQuotationType.Text = "cement";
            }
            else
            {
                txtQuotationType.Text = "tile";
            }

        }
        else
        {
            txtQuotationType.Text = "tile";
        }

        // ConfigureCrystalReports()
        ConfigureCrystalReports();          <----------------------------------------------------------------------------- I load Crystal Report here !

    } // end mb_fnInitFillAll()

/* *
 * Method to ConfigureCrystal Reports()
 * */
private void ConfigureCrystalReports()
{

    ConnectionInfo connectionInfo = new ConnectionInfo();
    connectionInfo.ServerName = mb_objConn.pstr_ConnString.pstr_server;
    connectionInfo.DatabaseName = mb_objConn.pstr_ConnString.pstr_initialCatalog;
    connectionInfo.UserID = mb_objConn.pstr_ConnString.pstr_userID;
    connectionInfo.Password = mb_objConn.pstr_ConnString.pstr_password;

    string reportPath = Server.MapPath("./reports/rptQuotation.rpt");

    ReportDocument rptDoc = new ReportDocument();

    rptDoc.Load(reportPath);

    cryRptVwr.ReportSource = rptDoc;

    //cryRptVwr.CssFilename = "http://localhost/crystalreportviewers115/css/default.css";
    //cryRptVwr.ToolbarImagesFolderUrl = "http://localhost/crystalreportviewers115/images/toolbar/";
    //cryRptVwr.GroupTreeImagesFolderUrl = "http://localhost/crystalreportviewers115/images/tree/";

    SetDBLogonForReport(connectionInfo, rptDoc);

    // ---------------------------------------------------------------------------------------------------

    StringBuilder sbConnStr = new StringBuilder();
    sbConnStr.Append("Server=" + mb_objConn.pstr_ConnString.pstr_server + ";");
    sbConnStr.Append("uid=" + mb_objConn.pstr_ConnString.pstr_userID + ";");
    sbConnStr.Append("password=" + mb_objConn.pstr_ConnString.pstr_password + ";");
    sbConnStr.Append("initial catalog=" + mb_objConn.pstr_ConnString.pstr_initialCatalog + ";");

    SqlConnection sqlConn = new SqlConnection(sbConnStr.ToString());

    //SqlConnection sqlConn = new SqlConnection("Server=st;uid=sa;password=adminis;initial catalog=dbMRP;");

    // --------------------------------- vwrQuotation -----------------------------
    SqlCommand comd;
    comd = new SqlCommand();
    comd.Connection = sqlConn;
    comd.CommandType = CommandType.Text;
    comd.CommandText = mb_fnConcatenateSelect_Quotation();

    //comd.Parameters.Add("@Companyname", SqlDbType.VarChar, 50);
    //if (TextBox1.Text.Trim() != "")
    //    comd.Parameters[0].Value = TextBox1.Text;
    //else
    //    comd.Parameters[0].Value = DBNull.Value;

    SqlDataAdapter sqlAdapter = new SqlDataAdapter();
    sqlAdapter.SelectCommand = comd;

    DataSet ds = new DataSet();
    ds.ReadXmlSchema(Server.MapPath("./dataSet/dsQuotation.xsd"));

    sqlAdapter.Fill(ds, "vwrQuotation");

    //// ---------------------------------- SProductPrices ---------------------------
    SqlCommand comd2;
    comd2 = new SqlCommand();
    comd2.Connection = sqlConn;
    comd2.CommandType = CommandType.Text;
    comd2.CommandText = mb_fnConcatenateSelect_QuotationDItem();

    //comd.Parameters.Add("@Companyname", SqlDbType.VarChar, 50);
    //if (TextBox1.Text.Trim() != "")
    //    comd.Parameters[0].Value = TextBox1.Text;
    //else
    //    comd.Parameters[0].Value = DBNull.Value;

    SqlDataAdapter sqlAdapter2 = new SqlDataAdapter();
    sqlAdapter2.SelectCommand = comd2;

    sqlAdapter2.Fill(ds, "vwrQuotationDItem");

    //// --------------------------------------------------------------------------------

    //// ---------------------------------- SProductPrices ---------------------------
    //SqlCommand comd3;
    //comd3 = new SqlCommand();
    //comd3.Connection = sqlConn;
    //comd3.CommandType = CommandType.Text;
    //comd3.CommandText = mb_fnConcatenateSelect_SProductPrices();

    ////comd.Parameters.Add("@Companyname", SqlDbType.VarChar, 50);
    ////if (TextBox1.Text.Trim() != "")
    ////    comd.Parameters[0].Value = TextBox1.Text;
    ////else
    ////    comd.Parameters[0].Value = DBNull.Value;

    //SqlDataAdapter sqlAdapter3 = new SqlDataAdapter();
    //sqlAdapter3.SelectCommand = comd3;

    //sqlAdapter3.Fill(ds, "vwrSProductPrices");

    //// --------------------------------------------------------------------------------

    //rptDoc.Database.Tables["vwrQuotationD"].ApplyLogOnInfo(tableLogOnInfo);
    //rptDoc.Database.Tables["vwrSProductPrices"].ApplyLogOnInfo(tableLogOnInfo);

    cryRptVwr.ReportSource = rptDoc;
    rptDoc.PrintOptions.PrinterName = "Epson LQ-2170 ESC/P 2";

    System.Drawing.Printing.PrintDocument printDocument = new System.Drawing.Printing.PrintDocument();
    printDocument.PrinterSettings.PrinterName = "Epson LQ-2170 ESC/P 2";

    for (int i = 0; i < printDocument.PrinterSettings.PaperSizes.Count; i++)
    {
        int rawKind;
        if (printDocument.PrinterSettings.PaperSizes.PaperName == "Fanfold 210 x 305 mm")
        {
            //rptDoc.PrintOptions.PaperSize = (CrystalDecisions.Shared.PaperSize) printDocument.PrinterSettings.PaperSizes.RawKind;
            rawKind = Convert.ToInt32(printDocument.PrinterSettings.PaperSizes.GetType().GetField("kind", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).GetValue(printDocument.PrinterSettings.PaperSizes));
            //crPrintOut.PrintOptions.PaperSize = rawKind;
            rptDoc.PrintOptions.PaperSize = (CrystalDecisions.Shared.PaperSize)rawKind;
        }
    }

    cryRptVwr.PrintMode = CrystalDecisions.Web.PrintMode.Pdf;

    rptDoc.PrintOptions.PaperOrientation = PaperOrientation.Portrait;
    rptDoc.PrintOptions.PaperSource = PaperSource.Tractor;

    cryRptVwr.EnableParameterPrompt = false;

    // - SubReport rptProductionBatchD
    ReportDocument rptDocSub = rptDoc.Subreports[0];
    rptDocSub.SetDataSource(ds);

    //string strSubReportName = rptDoc.Subreports[0].Name;

    SetDBLogonForReport(connectionInfo, rptDoc);
    SetDBLogonForReport(connectionInfo, rptDocSub);
    //SetDBLogonForReport(connectionInfo, rptDocSub2);
    // - end Sub Report rptProductionBatchD
    cryRptVwr.ReportSource = rptDoc;

    cryRptVwr.Visible = true;

    mb_objcryRptDoc = rptDoc; // for handling the problem with crystal report deficit.
    // crystal report 11 The maximum report processing jobs limit configured by your
    // system administrator has been reached.

    //rptDoc.PrintToPrinter(1, true, 0, 0);

    Session["rptDoc"] = mb_objcryRptDoc;          <--------------------------------------------------------------------Remember to store the report at Session
} // end ConfigureCrystalReports

private void SetDBLogonForReport(ConnectionInfo connectionInfo, ReportDocument _rptDoc)
{
    TableLogOnInfos tableLogOnInfos =
    cryRptVwr.LogOnInfo;
    foreach (TableLogOnInfo tableLogOnInfo in tableLogOnInfos)
    {
        tableLogOnInfo.ConnectionInfo = connectionInfo;
        foreach (CrystalDecisions.CrystalReports.Engine.Table table in _rptDoc.Database.Tables)
        {
            table.ApplyLogOnInfo(tableLogOnInfo);

            //rptDoc.Database.Tables["vwrSupplierSProductSProductTypeAll_NoPrice"].ApplyLogOnInfo(tableLogOnInfo);
            //rptDoc.Database.Tables["vwrSProductPrices"].ApplyLogOnInfo(tableLogOnInfo);
        }
    }

} // end SetDBLogonForReport(connectionInfo connectionInfo)


Problem Solved:

 

================================================================================================================================
The following is the code that it doesn’t overcome the problem:

// #############
// # Page Load #
// #############
protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
        FS = FORM_STATE.INIT;
        ViewState.Add("FS", FS);
        mb_fnSetFormState(FS);

        //Session["rptDoc"] = mb_objcryRptDoc;
        //// Restore Previous tbContainer.ActiveTab
        //if (Request.QueryString["tbContainer_ActiveTab"] != null)
        //{
        //    string str_tbContainer = Request.QueryString["tbContainer_ActiveTab"].ToString();

        //    switch (str_tbContainer)
        //    {
        //        case "tpPR":
        //            tbContainer.ActiveTab = tpPR;
        //            break;
        //        case "tpPRD":
        //            tbContainer.ActiveTab = tpPRD;
        //            break;
        //        default:
        //            tbContainer.ActiveTab = tpPR;
        //            break;
        //    } // end switch (str_tbContainer)
        //} // end if (Request.QueryString["tbContainer_ActiveTab"] != null)

    }
    else
    {
        FS = (FORM_STATE)ViewState["FS"];
        mb_fnSetFormState(FS);

        //mb_objcryRptDoc = (ReportDocument)Session["rptDoc"];

    } // end if ... else (!IsPostBack)

    // ------------------------------------------------
    // code to check user Login
    mb_objUserSession = new UserSession();

    if (!mb_objUserSession.pUser_Login)
    {
        Page.Response.Redirect("./frmUserNotPermitted.html");
    } // end if (!mb_objUserSession.pUser_Login)

    //// code to initial and bind all
    mb_fnInitFillAll();   <--------------------------------------------before I put Load Crystal Report function here

    // code to check user permissions
    mb_fnCheckPermissions();
} // end Page_Load(object sender, EventArgs e)

    /* *
     * method to init and fill all
     * */
    private void mb_fnInitFillAll()
    {
        mb_fnInit();

        // for user authentication
        mb_fnInitUserObject(); // vwrUserObject
        mb_fnInitUserGroupObject(); // vwrUserGroupObject

        if (Request.QueryString["Quotation_IDP"] != null && Request.QueryString["Quotation_IDN"] != null &&
            Request.QueryString["Quotation_IDR"] != null)
        {
            txtQuotation_IDP.Text = Request.QueryString["Quotation_IDP"].ToString();
            txtQuotation_IDN.Text = Request.QueryString["Quotation_IDN"].ToString();
            txtQuotation_IDR.Text = Request.QueryString["Quotation_IDR"].ToString();
            cbQuotation_ID.Checked = true;
            cbQuotation_ID.Enabled = false;
        }

        string strQueryString = "";

        if (Request.QueryString["URL"] != null)
        {
            strQueryString = Request.QueryString["URL"] + "?Quotation_IDP=" + txtQuotation_IDP.Text +
                "&Quotation_IDN=" + txtQuotation_IDN.Text +
                "&Quotation_IDR=" + txtQuotation_IDR.Text;
        } // end if (Request.QueryString["URL"] != null)

        if (Request.QueryString["URL2"] != null)
        {
            strQueryString += "&" + Request.QueryString["URL2"].ToString();
        } // end if (Request.QueryString["URL2"] != null)

        if (Request.QueryString["URL3"] != null)
        {
            strQueryString += "&" + Request.QueryString["URL3"].ToString();
        } // end if (Request.QueryString["URL3"] != null)

        this.hplBacktoQuotation.NavigateUrl=strQueryString;

        if (Request.QueryString["URL"] != null)
        {
            if (Request.QueryString["URL"].ToString().CompareTo("frmQuotationCMgt.aspx") == 0 ||
                Request.QueryString["URL"].ToString().CompareTo("frmrptQuotationC.aspx") == 0 )
            {
                txtQuotationType.Text = "cement";
            }
            else
            {
                txtQuotationType.Text = "tile";
            }

        }
        else
        {
            txtQuotationType.Text = "tile";
        } 
        ConfigureCrystalReports();   <--------------------------------------------------------- it appears here

    } // end mb_fnInitFillAll()

/* *
 * Method to ConfigureCrystal Reports()
 * */
private void ConfigureCrystalReports()
{

    ConnectionInfo connectionInfo = new ConnectionInfo();
    connectionInfo.ServerName = mb_objConn.pstr_ConnString.pstr_server;
    connectionInfo.DatabaseName = mb_objConn.pstr_ConnString.pstr_initialCatalog;
    connectionInfo.UserID = mb_objConn.pstr_ConnString.pstr_userID;
    connectionInfo.Password = mb_objConn.pstr_ConnString.pstr_password;

    string reportPath = Server.MapPath("./reports/rptQuotation.rpt");

    ReportDocument rptDoc = new ReportDocument();

    rptDoc.Load(reportPath);

    cryRptVwr.ReportSource = rptDoc;

    //cryRptVwr.CssFilename = "http://localhost/crystalreportviewers115/css/default.css";
    //cryRptVwr.ToolbarImagesFolderUrl = "http://localhost/crystalreportviewers115/images/toolbar/";
    //cryRptVwr.GroupTreeImagesFolderUrl = "http://localhost/crystalreportviewers115/images/tree/";

    SetDBLogonForReport(connectionInfo, rptDoc);

    // ---------------------------------------------------------------------------------------------------

    StringBuilder sbConnStr = new StringBuilder();
    sbConnStr.Append("Server=" + mb_objConn.pstr_ConnString.pstr_server + ";");
    sbConnStr.Append("uid=" + mb_objConn.pstr_ConnString.pstr_userID + ";");
    sbConnStr.Append("password=" + mb_objConn.pstr_ConnString.pstr_password + ";");
    sbConnStr.Append("initial catalog=" + mb_objConn.pstr_ConnString.pstr_initialCatalog + ";");

    SqlConnection sqlConn = new SqlConnection(sbConnStr.ToString());

    //SqlConnection sqlConn = new SqlConnection("Server=st;uid=sa;password=adminis;initial catalog=dbMRP;");

    // --------------------------------- vwrQuotation -----------------------------
    SqlCommand comd;
    comd = new SqlCommand();
    comd.Connection = sqlConn;
    comd.CommandType = CommandType.Text;
    comd.CommandText = mb_fnConcatenateSelect_Quotation();

    //comd.Parameters.Add("@Companyname", SqlDbType.VarChar, 50);
    //if (TextBox1.Text.Trim() != "")
    //    comd.Parameters[0].Value = TextBox1.Text;
    //else
    //    comd.Parameters[0].Value = DBNull.Value;

    SqlDataAdapter sqlAdapter = new SqlDataAdapter();
    sqlAdapter.SelectCommand = comd;

    DataSet ds = new DataSet();
    ds.ReadXmlSchema(Server.MapPath("./dataSet/dsQuotation.xsd"));

    sqlAdapter.Fill(ds, "vwrQuotation");

    //// ---------------------------------- SProductPrices ---------------------------
    SqlCommand comd2;
    comd2 = new SqlCommand();
    comd2.Connection = sqlConn;
    comd2.CommandType = CommandType.Text;
    comd2.CommandText = mb_fnConcatenateSelect_QuotationDItem();

    //comd.Parameters.Add("@Companyname", SqlDbType.VarChar, 50);
    //if (TextBox1.Text.Trim() != "")
    //    comd.Parameters[0].Value = TextBox1.Text;
    //else
    //    comd.Parameters[0].Value = DBNull.Value;

    SqlDataAdapter sqlAdapter2 = new SqlDataAdapter();
    sqlAdapter2.SelectCommand = comd2;

    sqlAdapter2.Fill(ds, "vwrQuotationDItem");

    //// --------------------------------------------------------------------------------

    //// ---------------------------------- SProductPrices ---------------------------
    //SqlCommand comd3;
    //comd3 = new SqlCommand();
    //comd3.Connection = sqlConn;
    //comd3.CommandType = CommandType.Text;
    //comd3.CommandText = mb_fnConcatenateSelect_SProductPrices();

    ////comd.Parameters.Add("@Companyname", SqlDbType.VarChar, 50);
    ////if (TextBox1.Text.Trim() != "")
    ////    comd.Parameters[0].Value = TextBox1.Text;
    ////else
    ////    comd.Parameters[0].Value = DBNull.Value;

    //SqlDataAdapter sqlAdapter3 = new SqlDataAdapter();
    //sqlAdapter3.SelectCommand = comd3;

    //sqlAdapter3.Fill(ds, "vwrSProductPrices");

    //// --------------------------------------------------------------------------------

    //rptDoc.Database.Tables["vwrQuotationD"].ApplyLogOnInfo(tableLogOnInfo);
    //rptDoc.Database.Tables["vwrSProductPrices"].ApplyLogOnInfo(tableLogOnInfo);

    cryRptVwr.ReportSource = rptDoc;
    rptDoc.PrintOptions.PrinterName = "Epson LQ-2170 ESC/P 2";

    System.Drawing.Printing.PrintDocument printDocument = new System.Drawing.Printing.PrintDocument();
    printDocument.PrinterSettings.PrinterName = "Epson LQ-2170 ESC/P 2";

    for (int i = 0; i < printDocument.PrinterSettings.PaperSizes.Count; i++)
    {
        int rawKind;
        if (printDocument.PrinterSettings.PaperSizes.PaperName == "Fanfold 210 x 305 mm")
        {
            //rptDoc.PrintOptions.PaperSize = (CrystalDecisions.Shared.PaperSize) printDocument.PrinterSettings.PaperSizes.RawKind;
            rawKind = Convert.ToInt32(printDocument.PrinterSettings.PaperSizes.GetType().GetField("kind", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).GetValue(printDocument.PrinterSettings.PaperSizes));
            //crPrintOut.PrintOptions.PaperSize = rawKind;
            rptDoc.PrintOptions.PaperSize = (CrystalDecisions.Shared.PaperSize)rawKind;
        }
    }

    cryRptVwr.PrintMode = CrystalDecisions.Web.PrintMode.Pdf;

    rptDoc.PrintOptions.PaperOrientation = PaperOrientation.Portrait;
    rptDoc.PrintOptions.PaperSource = PaperSource.Tractor;

    cryRptVwr.EnableParameterPrompt = false;

    // - SubReport rptProductionBatchD
    ReportDocument rptDocSub = rptDoc.Subreports[0];
    rptDocSub.SetDataSource(ds);

    //string strSubReportName = rptDoc.Subreports[0].Name;

    SetDBLogonForReport(connectionInfo, rptDoc);
    SetDBLogonForReport(connectionInfo, rptDocSub);
    //SetDBLogonForReport(connectionInfo, rptDocSub2);
    // - end Sub Report rptProductionBatchD
    cryRptVwr.ReportSource = rptDoc;

    cryRptVwr.Visible = true;

    mb_objcryRptDoc = rptDoc; // for handling the problem with crystal report deficit.
    // crystal report 11 The maximum report processing jobs limit configured by your
    // system administrator has been reached.

    //rptDoc.PrintToPrinter(1, true, 0, 0);

    Session["rptDoc"] = mb_objcryRptDoc;
} // end ConfigureCrystalReports

private void SetDBLogonForReport(ConnectionInfo connectionInfo, ReportDocument _rptDoc)
{
    TableLogOnInfos tableLogOnInfos =
    cryRptVwr.LogOnInfo;
    foreach (TableLogOnInfo tableLogOnInfo in tableLogOnInfos)
    {
        tableLogOnInfo.ConnectionInfo = connectionInfo;
        foreach (CrystalDecisions.CrystalReports.Engine.Table table in _rptDoc.Database.Tables)
        {
            table.ApplyLogOnInfo(tableLogOnInfo);

            //rptDoc.Database.Tables["vwrSupplierSProductSProductTypeAll_NoPrice"].ApplyLogOnInfo(tableLogOnInfo);
            //rptDoc.Database.Tables["vwrSProductPrices"].ApplyLogOnInfo(tableLogOnInfo);
        }
    }

} // end SetDBLogonForReport(connectionInfo connectionInfo)


 manpakhong

 
IP IP Logged
jijogeorge
Newbie
Newbie
Avatar

Joined: 11 Nov 2008
Online Status: Offline
Posts: 5
Quote jijogeorge Replybullet Posted: 28 Apr 2009 at 12:12am
I'm developing  a web application, which consists of reports. The problem is that, while exporting the crystal report to msExcel format (not data only) I am getting one extra row after each record. This is not happening in the case of Excel- dataonly format. So can any of you help me out to resolve this issue.
Jijo George
Software Engineer,
Bangalore, India
IP IP Logged
abubakar
Newbie
Newbie


Joined: 27 Jul 2009
Location: East Timor
Online Status: Offline
Posts: 3
Quote abubakar Replybullet Posted: 27 Jul 2009 at 10:30pm
Originally posted by BrianBischof

Glad it worked. The problem occurs because there is a timing problem with the Viewstate data and responding to mouse clicks in the Page_Load() event. But when you put the code in the Page_Init() event then this timing issue doesn't happen and your mouse clicks on the page navigation buttons will respond correctly.I talk about this in Chapter 14 of my CR.NET books. You can find out more about my books at
Amazon.com
or reading the Crystal
Reports eBooks
online.


Hi, just wanted to thank, the solution of page init worked for me also! The OP asked the exact same question which i was about to ask but thought i should google first, so found this.

regards,

..ab
IP IP Logged
abubakar
Newbie
Newbie


Joined: 27 Jul 2009
Location: East Timor
Online Status: Offline
Posts: 3
Quote abubakar Replybullet Posted: 27 Jul 2009 at 10:48pm
Originally posted by abubakar

Originally posted by BrianBischof

Glad it worked. The problem occurs because there is a timing problem with the Viewstate data and responding to mouse clicks in the Page_Load() event. But when you put the code in the Page_Init() event then this timing issue doesn't happen and your mouse clicks on the page navigation buttons will respond correctly.I talk about this in Chapter 14 of my CR.NET books. You can find out more about my books at
Amazon.com
or reading the Crystal
Reports eBooks
online.


Hi, just wanted to thank, the solution of page init worked for me also! The OP asked the exact same question which i was about to ask but thought i should google first, so found this.

regards,

..ab
IP IP Logged
abubakar
Newbie
Newbie


Joined: 27 Jul 2009
Location: East Timor
Online Status: Offline
Posts: 3
Quote abubakar Replybullet Posted: 27 Jul 2009 at 10:50pm
Originally posted by abubakar

Originally posted by abubakar

Originally posted by BrianBischof

Glad it worked. The problem occurs because there is a timing problem with the Viewstate data and responding to mouse clicks in the Page_Load() event. But when you put the code in the Page_Init() event then this timing issue doesn't happen and your mouse clicks on the page navigation buttons will respond correctly.I talk about this in Chapter 14 of my CR.NET books. You can find out more about my books at
Amazon.com
or reading the Crystal
Reports eBooks
online.


Hi, just wanted to thank, the solution of page init worked for me also! The OP asked the exact same question which i was about to ask but thought i should google first, so found this.

regards,

..ab


In case any1 doesnt know how to write a page_init on the code-behind, plz look at the following page:
http://weblogs.asp.net/rajbk/archive/2006/01/16/Page-Event-handlers-in-ASP.net-2.0.aspx

regards,

..ab
IP IP Logged
<< Prev Page  of 4 Next >>
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.016 seconds.