0

我在母版页中显示水晶报表时遇到问题...

这是我的来源:

<%@ Page Title="ADMIN | Home" Language="C#" MasterPageFile="~/admin/admin.Master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="kuesioner.admin.Default" Theme="CSSThemes" %>
<%@ MasterType VirtualPath="~/admin/admin.Master" %>
<%@ Register assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" namespace="System.Web.UI.DataVisualization.Charting" tagprefix="asp" %>
<%@ Register assembly="CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" namespace="CrystalDecisions.Web" tagprefix="CR" %>
<asp:Content ID="Content1" ContentPlaceHolderID="adminHead" runat="server"></asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="adminContent" runat="server">

    <CR:CrystalReportViewer ID="crv" runat="server" 
        AutoDataBind="True" ToolPanelView="None" 
       />
    <CR:CrystalReportSource ID="CrystalReportSource1" runat="server">
        <Report FileName="CrystalReport1.rpt">
        </Report>
    </CR:CrystalReportSource>
</asp:Content>

这在代码后面:

using CrystalDecisions.CrystalReports.Engine;

namespace kuesioner.admin
{
    public partial class Default : System.Web.UI.Page
    {
        String reportPath = System.Web.HttpContext.Current.Server.MapPath(@"\CrystalReport1.rpt");
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                ReportDocument crystalReport = new ReportDocument();
                crystalReport.Load(reportPath);
                crystalReport.Refresh();
                crv.ReportSource = crystalReport;
                crv.RefreshReport();
            }
            catch (Exception ex)
            {
                Response.Write("<script>alert('" + reportPath + "');</script>");

            }

        }
    }
}

这个结果:

https://docs.google.com/file/d/0ByOodqaOAeIQYTlyWW9tdV9DNUk/edit?usp=sharing

4

0 回答 0