我想要加載數據到會話中,以便在Crystal Report Viewer中單擊下一個按鈕時,應該從數據表中加載數據,而不是從數據庫中再次檢索數據。這裏去我的代碼...使用會話[]和頁面加載
ReportDocument rpt = new ReportDocument();
DataTable resultSet = new DataTable();
string reportpath = null;
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
if (Request.QueryString.Get("id") == "5")
{
string publication = Request.QueryString.Get("pub");
DateTime date = DateTime.Parse(Request.QueryString.Get("date"));
int pages = int.Parse(Request.QueryString.Get("pages"));
int sort = int.Parse(Request.QueryString.Get("sort"));
if (sort == 0)
{
reportpath = Server.MapPath("IssuesReport.rpt");
rpt.Load(reportpath);
DataTable resultSet1 = RetrievalProcedures.IssuesReport(date, publication, pages);
Session["Record"] = resultSet1;
}
DataTable report = (DataTable)Session["Record"];
rpt.SetDataSource(report);
CrystalReportViewer1.ReportSource = rpt;
我想這個代碼,但是當我點擊下一個按鈕,它給我的錯誤是無效的報告source..i猜測會話爲null所以它給我這個錯誤。
任何sugesstions我怎麼能解決這個...
這將有助於如果你的代碼了所有丟失的括號放回他們屬於哪裏。很難說出每個if語句的範圍。 – tvanfosson 2008-10-15 22:19:40