[英]Crystal Report runs query multiple times on page change
I have written the code for crystal report in the page_init() and it runs fine, but I have just noticed that when I switch report page index, means when I want to load second page of the report, the control again goes to the page load and whole report query runs again. 我已经在page_init()中编写了水晶报表的代码,并且运行良好,但是我刚刚注意到,当我切换报表页面索引时,这意味着当我想加载报表的第二页时,控件再次转到该页面。加载,整个报表查询将再次运行。
I have made a switch case and from query string I take the name which report is to be loaded, is there a way by which when I can minimize the report load time? 我做了一个转换案例,并从查询字符串中获取了要加载的报告的名称,有什么方法可以最大程度地减少报告的加载时间?
Is session a better idea? 会议是一个更好的主意吗?
If I write the code in (!Ispostaback), then only first page is loaded, when I try to switch second page, it shows no resource is available error. 如果我在(!Ispostaback)中编写代码,则仅加载第一页,当我尝试切换第二页时,它显示没有可用资源错误。
protected void Page_Init(object sender, EventArgs e)
{
try
{
String test = Request.QueryString["ReportType"];
ReportDocument report = new ReportDocument();
switch (testCondition)
{
case "Report":
var rpt1 = new LenderCompanyActionReport();
String lcarParam1 = Request.QueryString["Param1"];
String lcarParam2 = Request.QueryString["Param2"];
String lcarParam3 = Request.QueryString["Param3"];
String lcarParam4 = Request.QueryString["Param4"];
String lcarParam5 = Request.QueryString["Param5"];
List<Reportclass> lst2 = new ReportMethod().GetReport(lcarParam1, lcarParam2, lcarParam3, lcarParam4, lcarParam5);
rpt1.SetDataSource(lst2);
CRReportViewer.ReportSource = rpt1;
break;
}
您需要将rpt1添加到会话变量
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.