【发布时间】:2014-02-05 17:13:39
【问题描述】:
我正在使用 VS2012 在 ASP.NET C# 框架 4.0 中做一个项目。我需要创建一个 ReportViewer。我创建了报表 .rdlc,但是当我尝试在视图中显示它时,它显示为空白(报表查看器控件的工具栏出现并显示 1/1 页)。我在IE9、IE10、Mozilla和Chrome中测试过,结果都是一样的。
这是视图的代码:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="FitxaBolo.aspx.cs" Inherits="Activa_la_Cultura.Views.FitxaBolo" %>
<%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager runat="server" ID="ScriptManager1"></asp:ScriptManager>
<div>
<rsweb:ReportViewer AsyncRendering="False" id="ReportViewer1" runat="server" Height="1200px" Width="1200px"></rsweb:ReportViewer>
</div>
</form>
</body>
</html>
下面是代码:
if (!Page.IsPostBack)
{
var compañia = (string)HttpContext.Current.Session["compañia"];
var actividad = (string)HttpContext.Current.Session["actividad"];
var municipio = (string)HttpContext.Current.Session["municipio"];
var fecha = (string)HttpContext.Current.Session["fecha"];
var lugar = (string)HttpContext.Current.Session["lugar"];
var horario = (string)HttpContext.Current.Session["horario"];
var llegada = (string)HttpContext.Current.Session["llegada"];
var contacto = (string)HttpContext.Current.Session["contacto"];
var observaciones = (string)HttpContext.Current.Session["observaciones"];
var table = new DataSet1().Bolo;
table.AddBoloRow(compañia, actividad, municipio, fecha, lugar, horario, llegada, contacto, observaciones);
DataTable tb = (DataTable) table;
var rds = new ReportDataSource(table.TableName,tb);
ReportViewer1.LocalReport.DataSources.Clear();
ReportViewer1.ProcessingMode = ProcessingMode.Local;
ReportViewer1.LocalReport.ReportPath = Server.MapPath("~/FBolo_Report.rdlc");
ReportViewer1.LocalReport.DataSources.Add(rds);
ReportViewer1.LocalReport.Refresh();
}
我检查所有变量都有值,并且报告的路径是否正确。啊,我正在通过一个名为 Dataset1 的 DataSet 填写报告,这个表有一个名为 Bolo 的表,其中包含字段 compañia、fecha 等...
我在 web.config 中添加了与 reportviewer 控件相关的所有行,具体是版本 11。
提前致谢。
【问题讨论】:
标签: c# asp.net reportviewer