Report Viewer 2010陷入循环 [英] Report Viewer 2010 fall in loop
本文介绍了Report Viewer 2010陷入循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我曾尝试使用Report Viewer 2010,但是当我传递参数并运行应用程序时,它陷入了循环并且什么也不显示,我的应用程序位于.net 3.5中,但是当我将其转换为4.0时,发生了此问题,我尝试创建新的rdlc并使用Report Viewer 2010,但没有结果,
这是我的CS代码:
Hi everyone,
I have tried to using of report viewer 2010 but when I pass the parameter and run the application it fall in a loop and doesn''t show anything, my application was in .net 3.5 but when I convert that to 4.0 this issue happened, I tried to create a new rdlc and use of report viewer 2010 but no result,
this is my cs code :
protected void Page_Load(object sender, EventArgs e)
{
object exCarId = HttpContext.Current.Session[Constants.ExCarID];
if (exCarId != null)
{
string select = string.Format("Select * from ExCar where Id = {0} ", exCarId);
DataRow datarow = xps.GetDataRow(select);
if (datarow != null)
{
// string Herasat = File.ReadAllText(Server.MapPath("~/App_Data/Herasat.txt"));
// string ModirKol = File.ReadAllText(Server.MapPath("~/App_Data/ModirKol.txt"));
List<reportparameter> list = new List<reportparameter>();
list.Add(new ReportParameter("p1", Convert.ToString(datarow["CarNum"])));
list.Add(new ReportParameter("p2", Convert.ToString(datarow["CarType"])));
list.Add(new ReportParameter("p3", Convert.ToString(datarow["ShasiNum"])));
list.Add(new ReportParameter("p4", Convert.ToString(datarow["OwnerType"])));
list.Add(new ReportParameter("p5", Convert.ToString(datarow["MotorNum"])));
list.Add(new ReportParameter("p6", Convert.ToString(datarow["SerialNum"])));
ReportParameter[] reportParameters = list.ToArray();
rptViewer.LocalReport.SetParameters(reportParameters);
rptViewer.LocalReport.EnableExternalImages = true;
//rptViewer.LocalReport.EnableExternalImages = true;
rptViewer.LocalReport.Refresh();
rptViewer.DataBind();
}
}
}
thanks in advanced!
推荐答案
也许Refresh
导致Page_Load
,而在Page_Load
的末尾,Refresh
再次导致Page_Load
,这将会永远持续下去.
MaybeRefresh
causes aPage_Load
and at the end ofPage_Load
,Refresh
causes aPage_Load
again and this is going to continue for ever.
我只是添加这个
I just Add this
if (!IsPostBack)
{
//
}
我发现问题是由于回发造成的!
and i found that the issue was because of postback!
这篇关于Report Viewer 2010陷入循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文