我想要加载数据到会话中,以便在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