【发布时间】:2019-08-06 09:33:36
【问题描述】:
我有一个使用 ReportViewer 来显示 SSRS 服务器端报告的网站。我也有控件/文本框,用于使用 jQuery/AJAX 更新后面的数据。我想尽量避免任何页面重新加载。
我现在正在尝试在更新数据后刷新 ReportViewer,而无需重新加载页面。不幸的是,我不明白是否有办法将新数据(重新)加载到 ReportViewer 中。在 ReportViewer 控件中使用 refreshReport 方法只会使用旧数据重新呈现。
使用此代码更新数据,ReportViewer / 报告刷新,但使用旧数据。
我可以在不重新加载某种页面的情况下从数据库中获取新数据到报告中吗?
<script type="text/javascript">
function SaveData() {
var data = { text: $('#textBox').val() }
$.ajax({
type: "POST",
url: "ajax.aspx/SaveData",
data: JSON.stringify(data),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnSuccess,
failure: function (response) {
}
});
}
function OnSuccess(response) {
var clientViewer = $find("MainReportViewer");
if (clientViewer) {
clientViewer.refreshReport();
}
}
</script>
<rsweb:ReportViewer ID="MainReportViewer" runat="server" ProcessingMode="Remote" Width="100%" Height="100%" AsyncRendering="False" SizeToReportContent="True" ShowToolBar="False" ShowParameterPrompts="False">
<ServerReport ReportPath="/Rep/Rep" ReportServerUrl="http://localhost/reportserver" />
</rsweb:ReportViewer>
<button id="SaveButton" name="SaveButton" type="button" onclick="SaveData()" class="ui-button ui-widget ui-corner-all ui-button-icon-only"><span class="ui-icon ui-icon-disk"></span> </button>
【问题讨论】:
标签: c# asp.net reportviewer