0
votes

I have a website that uses a ReportViewer to display a SSRS serverside report. I also have controls/textboxes that are used to update the data behind using jQuery/AJAX. I want to try to avoid any page reloads.

I am now trying to refresh the ReportViewer after I have updated my data, without having the page reloaded. Unfortunately, I don't understand if there is a way to (re)load the new data into the ReportViewer. Using the refreshReport method in the ReportViewer control only rerenders with the old data.

Data gets updated with this code, the ReportViewer / report refreshes, but with the old data.

Can I get the new data from the database into the report without having some kind of page reload?

    <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>&nbsp;</button>
1

1 Answers

0
votes

Follow the below steps to make it work:

  1. Use The Timer like ASP.net Timer and JavaScript Timer
  2. refresh Data From Database every Tick and Use Tick Event
  3. the Elapse Time Out then Your Data Reload withOut Page Refresh

Dude these steps definitely work.

any queries please ask in comments.