Pass Asp.net Form values to Crystal Reports to get a filtered report RRS feed

  • Question

  • User908689340 posted

    Hi All,

    Presently I am stuck up with a problem in connecting ASP.NET form to Crystal Reports.

    I have a asp.net form where it contains a Dropdownbox with all the names of the student and below that there will 5 checkboxes which represents 5 subjects. maths,science,physics,General and Biology.

    If I select a student in the dropdown say "Student-1" and select two checkboxes Maths and Physics and Click the Submit Button.

    It must redirect to the page where the data will be filtered according to the inputs and displayed in crystal reports.

    To achieve this target solution . Please tell me your ideas and suggestions. I am very much glad to meet all here.

    Wednesday, January 2, 2013 11:31 AM


  • User-576945844 posted

    i used this code with textbox. if you want with dropdown and check box add dropdwn and check box in select statement.

     protected void Button2_Click(object sender, EventArgs e)
            SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["con"].ToString());
            SqlDataAdapter da = null;
            DataTable dt = new DataTable();
            DataTable dt1 = new DataTable();
            SqlCommand cmd = new SqlCommand("SELECT * FROM school WHERE studentid = @studentid ");
            cmd.Connection = con;
            cmd.Parameters.Add("@studentid", SqlDbType.Decimal).Value = TextBox1.Text;
            da = new SqlDataAdapter(cmd);
            if (dt.Rows.Count > 0)
                ReportDocument Report = new ReportDocument();
                TableLogOnInfos crtableLogoninfos = new TableLogOnInfos();
                TableLogOnInfo crtableLogoninfo = new TableLogOnInfo();
                ConnectionInfo crConnectionInfo = new ConnectionInfo();
                Tables CrTables;
                Report.SetDatabaseLogon("sa", "789", @"8", "report");
                CrystalReportViewer1.ReportSource = Report;
                CrystalReportViewer1.ReportSource = Report;
                CrTables = Report.Database.Tables;
                foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables)
                    crtableLogoninfo = CrTable.LogOnInfo;
                    crtableLogoninfo.ConnectionInfo = crConnectionInfo;
                //Report.PrintToPrinter(1, true, 1, 1);

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, January 21, 2013 12:59 AM