I call this static web method in jquery and I populate the table with the help of jquery Data is successfully display in table . In web form page there is one drop-down and two date-picker (from date & to date) according to selection of these values data is display in table now I want to create crystal report when I click on export button then table data ,drop down value & date-picker value will be display in report
I store dt in session and call that want to call in crystal report and I add crystalreportviewer in crystal report
I have web static webmethod i.e
[WebMethod]
public static string search_data(DateTime fromdate, DateTime todate, string region)
{
try
{
string result = "";
Ts1 td = new T1();
DateTime frDate = new DateTime(fromdate.Year, fromdate.Month, fromdate.Day, 0, 0, 0);
DateTime to_Date = new DateTime(todate.Year, todate.Month, todate.Day, 23, 59, 59);
List<griddataresult_Result> dq = td.griddataresult(frDate, to_Date, region).ToList();
DataTable dt = new DataTable();
dt.Columns.Add("ID", typeof(int));
dt.Columns.Add("OwnerName", typeof(string));
dt.Columns.Add("RegNo", typeof(string));
foreach (var c in dq)
{
dt.Rows.Add(c.ID, c.OwnerName, c.RegNo);
}
DataTable dtt= (DataTable)HttpContext.Current.Session["datagrid"];
result = DataSetToJSON(dt);
return result;
}
catch (Exception)
{
throw new Exception();
}
}
UPDATE
now i add this in webform
private void BindReport(ReportDocument crystalReport, DateTime fromdate, DateTime todate, string region)
{
TrackDataEntities1 t = new TrackDataEntities1();
crystalReport.Load(Server.MapPath("data.rpt"));
List<griddataresult_Result> dsc = t.griddataresult(fromdate, todate, region).ToList();
crystalReport.SetDataSource(dsc);
CrystalReportViewer1.ReportSource = crystalReport;
}
protected void Report_Click(object sender, EventArgs e)
{
DataTable dt = Session["datagrid"] as DataTable;
ReportDocument crystalReport = new ReportDocument();
//crystalReport.SetParameterValue("@fromdate", fromdate.Value);
//crystalReport.SetParameterValue("@todate", todate.Value);
//crystalReport.SetParameterValue("@region", regiondrop.SelectedValue);
BindReport(crystalReport,Convert.ToDateTime(fromdate.Value), Convert.ToDateTime(todate.Value), regiondrop.SelectedValue);
}
when i click on search then table data is display and then i when i click on report button table is disappear and blank report is display
Just add following code inside your ButtonClick Event
How to Export Crystal Report to PDF