gpt4 book ai didi

asp.net - 分页在报表查看器中不起作用

转载 作者:行者123 更新时间:2023-12-05 09:23:22 25 4
gpt4 key购买 nike

我目前在使用 Report Viewer 控件时遇到问题。我当前的项目是一个 MVC3 应用程序,我在其中链接了一个带有 Report Viewer 控件的 aspx 页面。该页面显示,但是,我根本无法翻阅结果。这是我的代码。

报表.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Report.aspx.cs" Inherits="SOSNG.Reports.Report" %>
<%@ 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>
<head id="Head1" runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="X-UA-Compatible" content="IE=8" />
<title>Report Viewer</title>
<link rel="stylesheet" href="../Content/Site.css"" type="text/css" />
</head>
<body>
<noscript><div class="noScript"><span class="errorMessage"></span>- This application works best with Javascript enabled.</div></noscript>
<div class="page">

<div id="MastHead">
<div id="MastHeadLeft"></div>

<%--<h1 id="ApplicationName"><span class="Skip"></span></h1>--%>

<div id="MastHeadRight"></div>

<div id="MasterMenu" class="clear">
</div>

</div>

<div id="MainPalette">
<div class="SubPalette"><h3 class="PaletteName"></h3>
<div class="SubPaletteContent">
<br />
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<div>
<rsweb:ReportViewer ID="SOSNGReportViewer" runat="server" AsyncRendering="False"
Height="100%" SizeToReportContent="False" Width="100%" ZoomPercent="100"
Font-Names="Verdana" Font-Size="8pt" InteractiveDeviceInfos="(Collection)"
WaitMessageFont-Names="Verdana" WaitMessageFont-Size="14pt"
ProcessingMode="Remote" ShowParameterPrompts="false">

</rsweb:ReportViewer>
</div>
</form>
</div>
</div>
</div>

<div id="Footer">
<div id="FooterSpan"></div>
<div id="FooterLeft"></div>
<div id="FooterRight"></div>
</div>

</div>

</body>
</html>

报表.aspx.cs

protected void Page_Load(object sender, EventArgs e)
{
//Report Type
var reportType = (string)Session["ReportType"];

//Search parameters
var searchFBINumber = string.Empty;
var searchVlanId = string.Empty;
var searchNetworkDevice = string.Empty;
var searchMACAddress = string.Empty;
var searchLocation = string.Empty;
var searchIPAddress = string.Empty;
var searchComment = string.Empty;

//Server Report setup
var serverReport = SOSNGReportViewer.ServerReport;
serverReport.ReportServerUrl = new Uri(ConfigurationManager.AppSettings["ReportServer"]);
serverReport.ReportPath = ConfigurationManager.AppSettings["ReportDirectory"] + reportType;

Microsoft.Reporting.WebForms.ReportParameter[] RptParameters;

//Switch on Report
switch (reportType)
{
case "CommentReport":
searchComment = (string)Session["Comment"];
if (!string.IsNullOrEmpty(searchComment))
{
RptParameters = new ReportParameter[1];
RptParameters[0] = new ReportParameter("Comment", searchComment);

this.SOSNGReportViewer.ServerReport.SetParameters(RptParameters);
this.SOSNGReportViewer.ServerReport.Refresh();
}
break;
case "FBINumberReport":
searchFBINumber = (string)Session["FBINumber"];
if (!string.IsNullOrEmpty(searchFBINumber))
searchFBINumber = null;

RptParameters = new ReportParameter[1];
RptParameters[0] = new ReportParameter("FBINumber", searchFBINumber);

this.SOSNGReportViewer.ServerReport.SetParameters(RptParameters);
this.SOSNGReportViewer.ServerReport.Refresh();
break;
case "IPAddressReport":
searchIPAddress = (string)Session["NetworkIPAddress"];
if (!string.IsNullOrEmpty(searchIPAddress))
{
RptParameters = new ReportParameter[1];
RptParameters[0] = new ReportParameter("IPAddress", searchIPAddress);

this.SOSNGReportViewer.ServerReport.SetParameters(RptParameters);
this.SOSNGReportViewer.ServerReport.Refresh();
}
break;
case "LocationReport":
searchLocation = (string)Session["Location"];
if (!string.IsNullOrEmpty(searchLocation))
searchLocation = null;

RptParameters = new ReportParameter[1];
RptParameters[0] = new ReportParameter("Location", searchLocation);

this.SOSNGReportViewer.ServerReport.SetParameters(RptParameters);
this.SOSNGReportViewer.ServerReport.Refresh();
break;
case "MACAddressReport":
searchMACAddress = (string)Session["MACAddress"];
if (!string.IsNullOrEmpty(searchMACAddress))
searchMACAddress = null;

RptParameters = new ReportParameter[1];
RptParameters[0] = new ReportParameter("MACAddress", searchMACAddress);

this.SOSNGReportViewer.ServerReport.SetParameters(RptParameters);
this.SOSNGReportViewer.ServerReport.Refresh();
break;
case "NetworkDeviceReport":
searchNetworkDevice = (string)Session["NetworkDevice"];
if (!string.IsNullOrEmpty(searchNetworkDevice))
searchNetworkDevice = null;

RptParameters = new ReportParameter[1];
RptParameters[0] = new ReportParameter("NetworkDevice", searchNetworkDevice);

this.SOSNGReportViewer.ServerReport.SetParameters(RptParameters);
this.SOSNGReportViewer.ServerReport.Refresh();
break;
case "VlanNumberReport":
searchVlanId = (string)Session["VlanId"];
if (!string.IsNullOrEmpty(searchVlanId))
{
RptParameters = new ReportParameter[1];
RptParameters[0] = new ReportParameter("VlanId", searchVlanId);

this.SOSNGReportViewer.ServerReport.SetParameters(RptParameters);
this.SOSNGReportViewer.ServerReport.Refresh();
}
break;
default:
break;
}
}

Report Viewer

最佳答案

我想通了。我需要在开始时对 !IsPostBack 进行检查。每个 PostBack 只是重新绑定(bind)数据并重置控件。应该知道这很简单。

关于asp.net - 分页在报表查看器中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22310260/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com