水晶报告没有显示

时间:2015-02-01 07:35:18

标签: c# asp.net crystal-reports

这是我的aspx页面代码

<body>
    <form id="form1" runat="server">
    <div>

    </div>
        <CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" AutoDataBind="True" />

    </form>
</body>

这就是我在页面加载时运行的内容

    ReportDocument rd = new ReportDocument();
    DBman db = new DBman(ConfigurationManager.ConnectionStrings["LocalSqlServer"].ConnectionString);
protected void Page_Load(object sender, EventArgs e)
{
    string type=Request.QueryString["type"];
    string query = (string)Session["query"];
    string bg = (string)Session["bg"];
    string rh = (string)Session["rh"];
    string key = (string)Session["key"];
    if (type =="type")
    {
        DataTable dt = db.getTable(query);//this works custom class to run query
       rd.Load(Server.MapPath("~/Staff/BrowseDonors.rpt"));
       rd.SetDataSource(dt);
       rd.SetParameterValue("BloodGroup",bg);
       rd.SetParameterValue("Rh", rh);
       rd.SetParameterValue("keyword", key);
       CrystalReportViewer1.ReportSource = rd;
       CrystalReportViewer1.DataBind();

    }

出错的是所有值都正确传递但页面是空白的,甚至报告查看器都没有显示

2 个答案:

答案 0 :(得分:0)

为什么不尝试在页面加载中创建一个新的Report Document实例。

protected ReportDocument rd;

protected void Page_Load(object sender, EventArgs e)
{
string type=Request.QueryString["type"];
    string query = (string)Session["query"];
    string bg = (string)Session["bg"];
    string rh = (string)Session["rh"];
    string key = (string)Session["key"];
    if (type =="type")
    {
       rd = new ReportDocument();
       DataTable dt = db.getTable(query);//this works custom class to run query
       string reportPath = Server.MapPath("~/Staff/BrowseDonors.rpt");
       rd.Load(reportPath);
       rd.SetDataSource((DataTable)dt);
       rd.SetParameterValue("BloodGroup",bg);
       rd.SetParameterValue("Rh", rh);
       rd.SetParameterValue("keyword", key);
       CrystalReportViewer1.ReportSource = rd;
    }

答案 1 :(得分:0)

发现iiS Express不支持Crystal报告认为是这种情况