Having problems previewing reports

I created a new "Project Server Report" in VS2013.Net 4.5. I added a data source and the test connection completed successfully. I added a DataSet using the "Use dataset built into my report" option, selecting the data source that was created earlier. The request type is a stored procedure with a single text parameter. In the report data window, I can right-click my DataSet, select Query and execute sproc. I see that the grid is correctly populated with my data.

However, when I try to create and view a report, it fails. I do the following:

Add a new report. Drop the table onto it from the toolbar. Start dragging the fields from my DataSet to the table. When I click the preview, I see the following

enter image description here

+5
source share
1 answer

This is a "HACK", but it will do what you ask.

<%@ Page Title="Home Page" Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication24._Default" %> <%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery/jquery-2.1.1.js"></script> <script type="text/javascript"> $(document).ready(function () { Sys.WebForms.PageRequestManager.getInstance().add_pageLoading(pageLoadingHandler); function pageLoadingHandler() { fixParameters(); } function fixParameters() { $("table[id^='ParametersGridReportViewer1']").find('input[type=text]').each(function () { if (isDate($(this).attr("value"))) { $(this).val($(this).val().substring(0, 10)); } }); } function isDate(date) { return ((new Date(date) !== "Invalid Date" && !isNaN(new Date(date)))); } }); </script> </head> <body> <form id="form1" runat="server"> <div> <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager> <rsweb:ReportViewer ID="ReportViewer1" runat="server" Font-Names="Verdana" Font-Size="8pt" ProcessingMode="Remote" WaitMessageFont-Names="Verdana" WaitMessageFont-Size="14pt" Width="1184px" ShowParameterPrompts="True"> <ServerReport ReportPath="/Report Project1/Report1" /> </rsweb:ReportViewer> </div> </form> </body> </html> 

Replace "ReportViewer1" with the name of your report viewer.
Basically, it will check all the input fields inside the report parameters table, and if any of them looks like dates, then it will delete the time during loading.

EDIT
Added full page code.

+3
source

Source: https://habr.com/ru/post/1208494/


All Articles