你的位置:首页 > ASP.net教程

[ASP.net教程]webfrom 下简单的RDLC


1、网上下载 下面的DLL  版本为11

Microsoft.ReportViewer.Common.dll ,

Microsoft.ReportViewer.ProcessingObjectModel.dll ,

Microsoft.ReportViewer.WebForms.dll,

 

2、界面

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="Demo.WebForm1" %><%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %><!DOCTYPE html><html ="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">  <div>    <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>     <rsweb:ReportViewer ID="ReportViewer1" runat="server"></rsweb:ReportViewer>      </div>  </form></body></html>

View Code

载入事件

protected void Page_Load(object sender, EventArgs e)    {           if (!IsPostBack)      {        //ReportViewer1.LocalReport.EnableExternalImages = true;        ReportViewer1.LocalReport.ReportPath = "Report1.rdlc";         //ReportViewer1.LocalReport.SetParameters(new ReportParameter(ReportParameter1, Guid.NewGuid().ToString()));        //DataTable dt = GetData();        //ReportDataSource rds = new ReportDataSource(DataSet1_DataTable1, dt);        //ReportViewer1.LocalReport.DataSources.Clear();        //ReportViewer1.LocalReport.DataSources.Add(rds);        ReportViewer1.LocalReport.Refresh();      }        }

View Code

3、和winform一样创建一个rdlc文件

Report1.rdlc

4、web.config

<??><!-- 有关如何配置 ASP.NET 应用程序的详细信息,请访问 http://go.microsoft.com/fwlink/?LinkId=169433 --><configuration> <system.web>  <customErrors mode="Off"/>  <compilation debug="true" targetFramework="4.0">   <assemblies>    <add assembly="Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845DCD8080CC91"/>   </assemblies>  </compilation>  <httpHandlers>   <add verb="*" path="Reserved.ReportViewerWebControl.axd" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"/>  </httpHandlers>  <pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/> </system.web> <system.webServer>  <validation validateIntegratedModeConfiguration="false"/>  <handlers>   <add name="ReportViewerWebControlHandler" preCondition="integratedMode" verb="*" path="Reserved.ReportViewerWebControl.axd" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"/>  </handlers> </system.webServer></configuration>

View Code