RDLC报表自定义数据源却无法显示的问题,急求各位指点!
我按照一些帖子上所教的方法进行自定义微软报表的数据源,可是运行起来发现页面在不停的刷新,报表一直处在“加载”的状态。源代码贴出来,大家看看怎么回事?开发工具是VS2010+SQL2008
后台:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Microsoft.Reporting.WebForms;
public partial class _Default : System.Web.UI.Page
{
MyDbEngine SqlEngine = new MyDbEngine();//这是我自己写的一个SQL执行类,没有问题的。
protected void Page_Load(object sender, EventArgs e)
{
DataTable dt = GetData();
ReportDataSource rds = new ReportDataSource("DataSet1", dt);
ReportViewer1.LocalReport.DataSources.Clear();
ReportViewer1.LocalReport.DataSources.Add(rds);
ReportViewer1.LocalReport.Refresh();
}
public DataTable GetData()
{string str="select * from MeetRoom_info";
DataSet ds= SqlEngine.ExecuteDataSet(str);
return ds.Tables [0];
}
}
页面代码:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register assembly="Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" namespace="Microsoft.Reporting.WebForms" tagprefix="rsweb" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<rsweb:ReportViewer ID="ReportViewer1" runat="server" Font-Names="Verdana"
Font-Size="8pt" InteractiveDeviceInfos="(集合)" WaitMessageFont-Names="Verdana"
WaitMessageFont-Size="14pt">
<LocalReport ReportPath="Report.rdlc">
<DataSources>
<rsweb:ReportDataSource DataSourceId="ObjectDataSource1" Name="DataSet1" />
</DataSources>
</LocalReport>
</rsweb:ReportViewer>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
TypeName="DataSet1TableAdapters."></asp:ObjectDataSource>
</form>
</body>
</html>
------解决方案--------------------
帮顶.....
------解决方案--------------------rdlc 没有绑数据源吧