locked
Regarding Crystal Report Printing Problem RRS feed

  • Question

  • Hi, I have created a "WEB APPLICATION" using "C#, ASP.NET, SQL SERVER 2008 and Visual Studio 2008". In that, the user can add,update and delete records, what ever the user added in respective modules. There are two Report links in the application, on click of them will display a "Report.aspx", here the user can filter the report as he like by selecting dropdowns ,from date and to date in the textBoxes. After selecting the appropiate dropdowns, the user will click on "Display" button. On Display Button Click event, I am passing the dropdownlist selected value and textbox values to a STORE PROCEDURE(SP). From the SP I am retrieving the filttered records into DataSet(DS). After that I am calling the SetDataSource funtion and assigning to DS.The resulted report, Which is fetched based on the filtering doned by the user from the data base is displayed below the "Display" button in the "Report.aspx' page. I am using "ReportViewer" control to display this report in "Report.aspx" page. The report is perfect and is currect. I don't have any problem up to this. I need to print this report, for this I had enable the "DisplayToolBar" Property of the "ReportViewer". There by I can have the "Print" ICON on the report. On click of this, I am getting Problem. Irrespective of the Filtering done by the user, It is showing entire records from the database in PDF file as well as in the "Report.aspx" page. How can I rectify this problem. Please help ASAP. It is very Urgent Please............
    In the DISPLAY button Click Event, I have written the following code. Please go through it. It might help in solving the issue. ----------------------------------------------------------------------------------------------------
    protected void btnDisplay_Click(object sender, EventArgs e)
    {
     Panel1.Visible = false;
    panel2.Visible = true;
    System.Data.DataSet ds = new System.Data.DataSet();
    using (SqlConnection mysqlconn = new SqlConnection("Data Source=LAKSHMINARAYANA;Initial Catalog=LOCAL;Integrated Security=True"))
    {
    mysqlconn.Open();
    using (SqlCommand mysqlcom = new SqlCommand("USP_GETREPORT", mysqlconn))
    {
    mysqlcom.CommandType = System.Data.CommandType.StoredProcedure;
    if (ddlLocation.SelectedIndex == 0)
    {
     mysqlcom.Parameters.Add("@ALLOTMENT_LOCATION_ID", System.Data.SqlDbType.Int).Value = 0;
     }
    else
    {
    mysqlcom.Parameters.Add("@ALLOTMENT_LOCATION_ID", System.Data.SqlDbType.Int).Value = ddlLocation.SelectedValue;
    }
    if (ddlTLName.SelectedIndex == 0)
    {
    mysqlcom.Parameters.Add("@ALLOTMENT_GROUP_ID", System.Data.SqlDbType.Int).Value = 0;
    }
    else
    {
    mysqlcom.Parameters.Add("@ALLOTMENT_GROUP_ID", System.Data.SqlDbType.Int).Value = ddlTLName.SelectedValue;
    }
    mysqlcom.Parameters.Add("@FROM_DATE", System.Data.SqlDbType.Date).Value = Convert.ToDateTime(txtFromDate.Text.Trim()).Date;
     mysqlcom.Parameters.Add("@TO_DATE", System.Data.SqlDbType.Date).Value = Convert.ToDateTime(txtToDate.Text.Trim()).Date;
    using (SqlDataAdapter mysqlda = new SqlDataAdapter(mysqlcom))
    {
    mysqlcom.ExecuteNonQuery(); mysqlda.Fill(ds);
    }
    }
    mysqlconn.Close();
    }
     string id = Request.QueryString["id"].ToString();
    if (id == "2")
    {
       CrystalReport2 cr2 = new CrystalReport2();
       cr2.SetDataSource(ds.Tables[0]);
       CrystalReportViewer1.ReportSource = cr2;
    }
    else if (id == "1")
    {
       CrystalReport1 cr1 = new CrystalReport1();
       cr1.SetDataSource(ds.Tables[0]);
       CrystalReportViewer1.ReportSource = cr1;
    }
    CrystalReportViewer1.DataBind();
    CrystalReportViewer1.Visible = true;
    }
    -----------------------------------------------------------------------------------------
    In the "Report.ASPX", this is the Crystal ReportViewer tag:
    -------------------------------------------------------------------------------------------------------------------
    <CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" Height="50px"
                                            Width="350px" TabIndex="7" DisplayToolbar="true" HyperlinkTarget="_self" />

    ------------------------------------------------------------------------------------------
    • Moved by Harry Zhu Wednesday, October 7, 2009 4:01 AM (From:Crystal Reports for Visual Studio)
    Thursday, October 1, 2009 6:56 AM

All replies