客户端SSRS调用
VS2010中需添加: <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> 否则不能运行。
前台:
1 <%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
2 Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>
3
4 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
6 <html xmlns="http://www.w3.org/1999/xhtml">
7 <head runat="server">
8 <title></title>
9 </head>
10 <body>
11 <form id="form1" runat="server">
12 <div>
13 <asp:ScriptManager ID="ScriptManager1" runat="server">
14 </asp:ScriptManager>
15 <rsweb:ReportViewer ID="rpvDemo" runat="server" Font-Names="Verdana"
16 Font-Size="8pt" InteractiveDeviceInfos="(集合)" WaitMessageFont-Names="Verdana"
17 WaitMessageFont-Size="14pt">
18 <LocalReport ReportPath="Report1.rdlc">
19 <DataSources>
20 <rsweb:ReportDataSource DataSourceId="ObjectDataSource1" Name="DataSet1" />
21 </DataSources>
22 </LocalReport>
23 </rsweb:ReportViewer>
24 <asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
25 SelectMethod="GetData"
26 TypeName="WebApplication1.db_WebDemoDataSetTableAdapters.WebDemo_UserInfoTableAdapter">
27 </asp:ObjectDataSource>
28 </div>
29 </form>
30 </body>
31 </html>
32
后台:
1 using System;
2 using System.Collections .Generic;
3 using System.Linq;
4 using System.Web;
5 using System.Web.UI;
6 using System.Web.UI.WebControls;
7 using Microsoft.Reporting.WebForms;
8 using WebApplication1.db_WebDemoDataSetTableAdapters;
9
10 namespace WebApplication1
11 {
12 public partial class WebForm1 : System.Web.UI.Page
13 {
14 protected void Page_Load(object sender, EventArgs e)
15 {
16 if (!IsPostBack)
17 {
18 this.rpvDemo.ShowPrintButton = false;//隐藏页面的“打印”按钮
19 this.rpvDemo.ProcessingMode = ProcessingMode.Local;//设置处理模式为当地
20 this.rpvDemo.LocalReport.ReportPath = "Report1.rdlc";//获取本地报表的路径
21 ReportDataSource ds = new ReportDataSource();//构造数据源
22 ds.Name = "DataSet1";//获取报表的数据源名称
23 ds.Value = new WebDemo_UserInfoTableAdapter().GetData();//获取报表的值
24 this.rpvDemo.LocalReport.DataSources.Add(ds);//添加数据源
25 }
26 }
27 }
28 }