带有更新面板的水晶报表asp.net [英] Crystal report with update panel asp.net

查看:56
本文介绍了带有更新面板的水晶报表asp.net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个asp.net网站.

I'm developing an asp.net web site.

在该网站上,我需要借助Crystal Report来显示报告.

In that web site i need to display a report with the help of crystal report.

<asp:UpdatePanel ID="uPnlMain" runat="server" UpdateMode="Conditional">
    <ContentTemplate> 
        <table>
            <tr>
                <td>
                    <asp:Button ID="btnSave" runat="server" 
                            CssClass="btn" OnClick="btnSave_Click" Text="Show"/>
                </td>
            </tr>
            <tr>
                <td>
                    <CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" AutoDataBind="true" />                
                </td>
            </tr>
        </table>
    </ContentTemplate>
</asp:UpdatePanel>

报告源代码

protected void btnSave_Click(object sender, EventArgs e)
{
        ReportDocument crystalReport = new ReportDocument();
        crystalReport.Load(Server.MapPath("Reports/crptBalance.rpt"));
        DSBalance dsCustomers = GetData(@"
DECLARE @DateFrom DATETIME;
DECLARE @p_Dt DATETIME;
SELECT @p_Dt = '2013-11-14 00:00:00';
SELECT TOP 1 @DateFrom = vdate FROM tblLedger WHERE fdocid = 1 AND vdate <= @p_Dt ORDER BY vdate DESC;
IF @DateFrom IS NULL BEGIN
    SELECT TOP 1 @DateFrom = OpBalDate FROM tblTrnsOpBalMaster WHERE OpBalDate <= @p_Dt ORDER BY OpBalDate DESC;
END
SELECT Y.Customer,
    CONVERT(VARCHAR,Y.Date,103) AS [Date],
    UPPER(Y.Description) AS Description,
    Y.[Due Days],
    Y.Debit,
    Y.Credit,
    CASE WHEN Y.[Balance] >= 0 THEN Y.[Balance] ELSE -1 * Y.[Balance] END AS [Balance],
    CASE WHEN Y.[Balance] >= 0 THEN 'DR' ELSE 'CR' END AS [TP] FROM 
(
    SELECT X.Customer,
        X.Date,
        X.Description,
        X.[Due Days],
        X.Debit,
        X.Credit,
        X.Debit - X.Credit AS [Balance] FROM 
    (
        SELECT CUS.nm + ',  ' + cus.[add] AS [Customer],
            vdate [Date],
            narration AS [Description],
            DATEDIFF(DAY, vdate, GETDATE()) AS [Due Days],
            CASE WHEN amttype = 'DR' THEN amt ELSE 0.0000 END AS Debit,
            CASE WHEN amttype = 'CR' THEN amt ELSE 0.0000 END AS Credit
        FROM tblledger LED
            LEFT OUTER JOIN tblCustomer CUS ON (LED.acid = CUS.id)
        WHERE acid IN (42,7) AND vdate >= @DateFrom AND vdate < @p_Dt 
    )X
)Y
ORDER BY Y.Customer,Y.Date");
        crystalReport.SetDataSource(dsCustomers);
        CrystalReportViewer1.ReportSource = crystalReport;
}

我的问题是,当我在更新面板中使用Crystal Report Viewer时,报告中没有显示任何数据.

My problem is that when i use crystal report viewer inside a update panel it doesn't show any data in the report.

我的意思是说它显示空白报告.

I mean to say that it shows blank report.

与没有更新面板的情况一样,效果很好.

Where as without update panel it works fine.

任何人都可以告诉我是什么问题

Can any one tell me what is the problem

推荐答案

我认为您缺少更新面板中的报告源",这就是为什么它可能无法正常工作的原因.另一方面,Crystal报表在更新面板"中似乎效果不佳.我个人从未尝试过(我建立了Reports Portal,但使用了单独的页面),但是已经阅读了很多.即使人们将其显示在更新面板中,工具栏上的打印"和导出"按钮也常常不起作用.这篇帖子非常有用,它建议您可以采用几种不同的解决方案来获得可接受的解决方案.

I think you are missing the Report Source in the update panel, which is why it may not work. On the other hand, Crystal reports don't seem to work very well in Update Panels. I personally have never tried it (I built a Reports Portal but used separate pages) but have read quite a bit about it. Even when people get it to display in the update panel, often times the print and export buttons on the toolbar won't work. This post is very informative and suggests several different solutions you could pursue to get an acceptable solution.

这篇关于带有更新面板的水晶报表asp.net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆