Mvc调用Reporting Service

1、aspx页面

<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/site.Master" Inherits="System.Web.Mvc.ViewPage" %>

<%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
    Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>

<script runat="server">
    void Page_Load(object sender, EventArgs e)
    {
        if (ViewData["ReportData"] != null)
        {
            Dictionary<string, string> dic = ViewData["ReportData"] as Dictionary<string, string>;

            ReportViewer1.ServerReport.ReportServerUrl = new Uri("http://" + dic["IPstr"] + "/reportserver");
            ReportViewer1.ServerReport.ReportPath = "/MerchantManagerReports/V_DeviceInMerchant";
            ReportViewer1.ProcessingMode = ProcessingMode.Remote;
            ServerReport serverReport = ReportViewer1.ServerReport;
            List<ReportParameter> list = new List<ReportParameter>();
            list.Add(new ReportParameter("OrgID", dic["orgId"] == MerchantManagerApp.MmaPermissions.OrgManager.YadaOrgId ? null : dic["orgId"]));
            list.Add(new ReportParameter("MerchantNo", dic["MerchantNo"] == "" ? null : dic["MerchantNo"]));
            list.Add(new ReportParameter("TerminalID", dic["TerminalID"] == "" ? null : dic["TerminalID"]));
            list.Add(new ReportParameter("Contact", dic["Contact"] == "" ? null : dic["Contact"]));
            serverReport.SetParameters(list);
        }
    }
</script>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Index
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <script src="<%=VirtualPathUtility.ToAbsolute("~/Scripts/jquery-1.4.1.js") %>" type="text/javascript"></script>

    <script src="<%=VirtualPathUtility.ToAbsolute("~/Scripts/jquery.validate.js") %>"
        type="text/javascript"></script>

    <script src="<%=VirtualPathUtility.ToAbsolute("~/Scripts/MvcReportViewStyle.js") %>"
        type="text/javascript"></script>//去掉webForm 调用Reporting Service时,出现的三层滚动条

    <table id="reportCondition">
        <tr>
            <td valign="top">
                <%  Dictionary<string, string> dic = ViewData["ReportData"] as Dictionary<string, string>;
                    string merchantNo = "", terminalID = "", Contact = "";
                    if (dic != null)
                    {
                        merchantNo = dic["MerchantNo"];
                        terminalID = dic["TerminalID"];
                        Contact = dic["Contact"];
                    }
                    using (Html.BeginForm("DeviceInMerchant", "ReportView"))
                    {%>
                <table>
                    <tr>
                        <td>
                            机构:
                        </td>
                        <td>
                            <select name="Orgs" id="Orgs" >
                                <% string orgStr = ""; string orgId = dic == null ? "" : dic["orgId"];

                                   IEnumerable<CommOrganization> orgs = ViewData["orgs"] as IEnumerable<CommOrganization>;
                                   foreach (var item in orgs)
                                   {
                                       orgStr += "<option value=/"" + item.ID + "/" ";
                                       if (orgId == item.ID.ToString())
                                           orgStr += "selected=/"selected/"";
                                       orgStr += ">" + item.Name + "</option>";
                                   } %>
                                <%= orgStr%>
                            </select>
                        </td>
                        <td>
                            商户号
                        </td>
                        <td>
                            <%=Html.TextBox("MerchantNo", merchantNo)%>
                        </td>
                        <td>
                            终端号
                        </td>
                        <td>
                            <%=Html.TextBox("TerminalID", terminalID)%>
                        </td>
                        <td>
                            联系人
                        </td>
                        <td>
                            <%=Html.TextBox("Contact", Contact)%>
                        </td>
                        <td>
                            <input type="submit" value="查询" />
                        </td>
                    </tr>
                </table>
                <%} %>
            </td>
        </tr>
    </table>
    <form id="form1" runat="server">
    <rsweb:ReportViewer ID="ReportViewer1" runat="server" Font-Names="Verdana" Font-Size="8pt"
        SizeToReportContent="True" ProcessingMode="Remote" Width="100%" BackColor="#eaf6fc"
        ShowFindControls="False" ToolTip="商户档案" ShowBackButton="true" ShowZoomControl="true"
        AsyncRendering="true" ZoomMode="percent" ShowRefreshButton="true" Height="500px">
    </rsweb:ReportViewer>
    </form>
</asp:Content>
2、cs

 public ActionResult DeviceInMerchant()
        {
            ViewData["orgs"] = GetOrgList();
            return View();
        }

        [AcceptVerbs(HttpVerbs.Post)]
        public ActionResult DeviceInMerchant(FormCollection collection)
        {
            Dictionary<string, string> dic = new Dictionary<string, string>();
            dic.Add("IPstr", reportServerIp);
            dic.Add("MerchantNo", collection["MerchantNo"]);
            dic.Add("TerminalID", collection["TerminalID"]);
            dic.Add("Contact", collection["Contact"]);
            dic.Add("orgId", collection["Orgs"]);
            ViewData["orgs"] = GetOrgList();
            ViewData["ReportData"] = dic;
            return View();
        }

 

 

 

运行页面时,调整窗口适当大小,你最多会内外三层滚动条,如何去掉多余滚动条,参见调用 Reporting Service 时,怎么去掉滚动条

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值