0

这是我在 Win 2000 和 IIS3 上托管时可以工作的 .Net 2 ASP.Net 代码。

'在 Page_Load 中,如果它不是 PostBack,则删除缓存的报表对象,以便稍后的代码强制重建它。

在 Win2000 和 IIS3 下,当我单击链接以重新加载页面时,在 Page_Load 中它会调用 Session.Remove("ReportObject"),然后在 FillRptParams 中实现 Session("ReportObject") 为 Nothing 并重新加载它。

我最初将所有会话代码放入其中以确保在 Crystal Report 页面请求之间它不会继续进入数据库,它只会从会话变量中拉出 ReportObject 显示下一页。

现在我已经切换到 Win 2003 和 IIS6,我总是得到相同的报告,即使像我以前那样单击链接时,这基本上会导致 IsPostBack 为假并删除 Session 对象。

我希望它可能会在 IIS6 下进行一些设置,使其表现得像以前一样。

     Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

     If Not Page.IsPostBack Then
       Session.Remove("ReportObject")
     End If

     End Sub

     Sub FillRptParams(ByVal snavcode As String, Optional ByVal CrystalOrPDForEXCEL As String = "")

     If Not Session("ReportObject") Is Nothing Then
         bReportCached = True
     Else            
        bReportCached = False
     End If

     oSqlCmd = New SqlCommand

     If bReportCached Then
         orpt = Session("ReportObject")

     Else
           orpt = New rptUsageSummaryNew
           oSqlCmd.CommandText = "HOSP_RPT_UsageAllSummary"

           oDS = oDataAccess.GetReportDataSet(Session("Group"), oSqlCmd)
           orpt.SetDataSource(oDS)

           'Cache the report object so we don't have to load it again next time
           Session.Remove("ReportObject")
           Session.Add("ReportObject", orpt)
     End If

     End Sub
4

1 回答 1

0

在 Page_init 事件中移动您的代码,而不是在 page_load 中。并在您移动它时抑制您的“如果回发代码”。

于 2016-08-12T06:36:52.477 回答