在另一页的div中加载一个包含reportviewer的aspx页面

时间:2017-06-03 09:20:06

标签: javascript c# jquery

Reportviewer aspx代码如下所示

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.Reporting.WebForms;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;

public partial class PresentationLayer_Reports_ReportViewer : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
   {
      if (!IsPostBack)
    {

        ReportViewer.LocalReport.ReportPath = Server.MapPath("~/Reports/Details.rdlc");

        spGetDetails_Report dsCustomers1 = GetData("spGetDetails_Report");
        ReportDataSource datasource1 = new ReportDataSource("spGetDetails_Report", dsCustomers1.Tables[0]);
        ReportViewer.LocalReport.DataSources.Clear();
        ReportViewer.LocalReport.DataSources.Add(datasource1);
        ReportViewer.ShowPrintButton = true;
        ReportViewer.AsyncRendering = false;           
    }
}

public spGetDetails_Report GetData(string query)
{
    string conString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
    SqlCommand cmd = new SqlCommand(query);
    using (SqlConnection con = new SqlConnection(conString))
    {
        using (SqlDataAdapter sda = new SqlDataAdapter())
        {               
            cmd.Connection = con;
            sda.SelectCommand = cmd;
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("CId", 1);
            cmd.Parameters.AddWithValue("PStartDate", "2010/10/01");
            cmd.Parameters.AddWithValue("PEndDate", "2011/05/05");
            cmd.Parameters.AddWithValue("SId", 0);


                using (spGetDetails_Report dsCustomers = new 
spGetDetails_Report())
            {
                sda.Fill(dsCustomers, "spGetDetails_Report");
                return dsCustomers;
            }
        }
    }
}

在另一个页面中,我使用下面的方法调用ReportViewer.aspx,但是查看器没有加载任何数据,工具栏也被禁用

jQuery("#ReportContainer").load(('ReportViewer.aspx'));

在另一个页面中,我使用下面的方法调用ReportViewer.aspx,但是查看器没有加载任何数据,工具栏也被禁用

0 个答案:

没有答案