Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Having trouble previewing reports

I've created a new "Report Server Project" in VS2013 .Net 4.5. I've added a data source and the test connection succeeds. I've added a DataSet using the "Use a dataset embedded in my report" option choosing the data source previously created. The query type is Stored Procedure with a single text parameter. In the report data box I can right click my DataSet, choose Query, and execute the sproc. I see a grid populated correctly with my data.

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

Add a new report. Drop a table on it from the toolbox. Start dragging fields from my DataSet onto the table. When I hit preview I see the following

enter image description here

like image 285
Jt2ouan Avatar asked Sep 29 '22 06:09

Jt2ouan


1 Answers

This is a "HACK" but it will do what you are asking.

<%@ 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 the "ReportViewer1" with the name of your report viewer.
This basically will check all input fields inside the report parameter table and if any of them look like dates then it will remove the time while loading.

EDIT
Added entire page code.

like image 175
goroth Avatar answered Oct 16 '22 09:10

goroth