我正在开发一个asp.net 网站。
在那个网站上,我需要在水晶报告的帮助下显示一份报告。
html
<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;
}
我的问题是,当我在更新面板中使用水晶报表查看器时,它不会在报表中显示任何数据。
我的意思是说它显示空白报告。
如果没有更新面板,它可以正常工作。
谁能告诉我是什么问题