private void btnShow_Click(object sender, EventArgs e) { string strSelection = ""; CrystalDecisions.CrystalReports.Engine.ReportClass ReportObject; //To Select the data by parameters you shound add here if (!txtSearchingParameter1.Text.Trim().Equals(string.Empty)) { strSelection = strSelection + (strSelection == "" ? "" : " And "); strSelection = strSelection + "{CrystalReportWithVS2012_ReportClasses_ReportData_AMIN_ITEMS.NAME}='" + txtSearchingParameter1.Text.Trim() + "'"; } List <AMIN_ITEMS> list = new List <AMIN_ITEMS>(); list = LoadData(); ReportObject = new TestCrystalReport(); ReportObject.SetDataSource(list); //To show value directly in the crystal report you should add a parameter and submet data like this CrystalDecisions.Shared.ParameterDiscreteValue crParameter1 = new CrystalDecisions.Shared.ParameterDiscreteValue(); crParameter1.Value = txtShowValue1.Text; ReportObject.SetParameterValue("FirstParameter", crParameter1); CrystalDecisions.Shared.ParameterDiscreteValue crParameter2 = new CrystalDecisions.Shared.ParameterDiscreteValue(); crParameter2.Value = txtShowValue2.Text; ReportObject.SetParameterValue("SecondParameter", crParameter2); ReportAccess.ShowReport(ReportObject, strSelection); }
public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport() { TestCrystalReport rpt = new TestCrystalReport(); rpt.Site = this.Site; return(rpt); }