水晶报告中的呼叫会话

时间:2016-08-09 07:36:18

标签: c# asp.net crystal-reports crystal-reports-2013

我在jquery中调用这个静态Web方法,并在jquery的帮助下填充表 数据成功显示在表格中。在网页表单页面有一个下拉菜单和两个日期选择器(从日期和日期)根据这些值的选择数据显示在表中现在我想创建水晶报告当我点击导出按钮然后表数据,下降值&日期选择器值将显示在报告中

我将dt存储在会话中并调用想要在水晶报表中调用并在水晶报表中添加crystalreportviewer

我有网络静态网络方法,即

[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();
        }
 }

更新

现在我在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);

    }

当我点击搜索然后显示表格数据然后我点击报表按钮表时消失并显示空白报表

1 个答案:

答案 0 :(得分:0)

只需在ButtonClick事件

中添加以下代码即可
IFS=';'
for x in string
do
    version = $x
done

How to Export Crystal Report to PDF