将数据从Web表单(标签和文本)传递到水晶报表页面

时间:2012-02-11 15:50:55

标签: sql crystal-reports webforms

我想将网页表单中的值传递给水晶报表页面。这是我的代码:

CrystalDecisions.CrystalReports.Engine.ReportDocument report;  
CrystalDecisions.CrystalReports.Engine.TextObject X;        
report= new CrystalReport1();                         
X = report.ReportDefinition.Sections["Section1"].ReportObjects["text2"] as extObject;              
X.Text = Label3.Text;  
CrystalReportViewer1.ReportSource = CrystalReportSource1; 
CrystalReportViewer1.DataBind();       
CrystalReportViewer1.RefreshReport(); 

表单正在调试,但它给了我一条消息(水晶报表viewer1的顶部):

Object reference not set to an instance of an object 

我需要帮助,我该如何解决?

1 个答案:

答案 0 :(得分:0)

我使用以下代码完成了这个!试试这个...

TextObject X =(TextObject)report.ReportDefinition.Sections["Section1"].ReportObjects["text2"];
X.Text = Label3.Text;