i am doing a project in which i have to generate a report in which the report should show only records based on user input
i.e from employees table user is providing input from dropdownlist as the employees who belong to manager_id 100 and the report should populate while clicking a button
thanks in advance
Ashok
Loading
Pravin GhadgePosted Dec 3, 2011, 7:52 AM
On your form's button Click Event:
private void btnReport_Click(object sender, EventArgs e)
{
try
{
View_Reports("Select * from tblname where manager_id='" +cmbName.Text+'", "rptEmp.rpt"");
Report.ShowDialog();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void View_Reports(string Querry, string CRReportName)
{
string reppath = "";
con = oDAL.OpenConnection();
SqlDataAdapter da1 = new SqlDataAdapter(Querry, con);
DataSet ds = new DataSet();
da1.Fill(ds);
rd = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
reppath =Application.Startuppath + "\\Reports\\" + CRReportName + "";
rd.Load(reppath);
rd.SetDataSource(ds.Tables[0]);
crystalReportViewer1.ReportSource = rd;
crystalReportViewer1.ShowCloseButton = true;
}
This may help you