在ASP.NET中调用Report Service 报表流程

来源:互联网 发布:淘宝搜索技术 黑搜索 编辑:程序博客网 时间:2024/04/29 13:46

1、定义Report Service 报表

2、ASP.NET展示页面代码

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="ecSunExpenseSystemWeb.WebUI.Desktop.Report.WebForm1" %>

<%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=9.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>
    <style type="text/css">
        #form1
        {
            height: 441px;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
         <table border="0" cellpadding="0" cellspacing="0">
            <tr>
                <td>
                    日期:
                </td>
                <td>
                    <asp:DropDownList ID="dropdownlistYear" runat="server">
                    </asp:DropDownList>
                    年
                    <asp:DropDownList ID="dropdownlistMonth" runat="server">
                    </asp:DropDownList>
                    月
                </td>
                <td>
                    <asp:Button ID="buttonShowReport" runat="server" CssClass="buttonstyle" Text="显示报表" OnClick="buttonView_Click"   />
                     
                </td>               
            </tr>
        </table>
    </div>
    <div>
       <rsweb:reportviewer id="ReportViewer1" runat="server" height="300px" width="100%"
        DocumentMapCollapsed="True" ProcessingMode="Remote" ShowBackButton="True" ShowCredentialPrompts="False"
        ShowDocumentMapButton="False" ShowParameterPrompts="False" SizeToReportContent="True"></rsweb:reportviewer>

    </div>
    </form>
</body>
</html>

3、ASP.NET后台代码:

 string itemDeptID = "G01001007276";
           
            //设置报表参数

            ReportParameter[] paras = new ReportParameter[1];
            paras[0] = new ReportParameter("DepartID", itemDeptID);

            ReportViewer1.ProcessingMode = ProcessingMode.Remote;
            ReportViewer1.ServerReport.ReportServerUrl = new Uri(ConfigurationManager.AppSettings["ReportServer"]);
            ReportViewer1.ServerReport.ReportPath = "/ExpDeptDetail";
            this.ReportViewer1.ServerReport.SetParameters(paras);

            this.ReportViewer1.ServerReport.Refresh();

 

原创粉丝点击