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.
radhekrishna
Member
104 Points
129 Posts
Pass Asp.net Form values to Crystal Reports to get a filtered report
Jan 02, 2013 03:31 PM|LINK
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.
Abdul Muqeet
Member
82 Points
428 Posts
Re: Pass Asp.net Form values to Crystal Reports to get a filtered report
Jan 21, 2013 04:59 AM|LINK
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(); con.Open(); 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); dt.Clear(); da.Fill(dt); if (dt.Rows.Count > 0) { ReportDocument Report = new ReportDocument(); Report.Load(Server.MapPath("~/CrystalReport.rpt")); Report.SetDataSource(dt); 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; CrystalReportViewer1.DataBind(); CrTables = Report.Database.Tables; foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables) { crtableLogoninfo = CrTable.LogOnInfo; crtableLogoninfo.ConnectionInfo = crConnectionInfo; CrTable.ApplyLogOnInfo(crtableLogoninfo); } //Report.Refresh(); //Report.PrintToPrinter(1, true, 1, 1); con.Close(); }